private boolean canReplace( World w, IBlockState state, Block block, BlockPos pos ) { return block.isReplaceable( w, pos ) && !( block instanceof IFluidBlock ) && !( block instanceof BlockLiquid ) && !state.getMaterial().isLiquid(); }
private boolean placeBlock(ItemStack itemstack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float xOffset, float yOffset, float zOffset) { IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if(!block.isReplaceable(world, pos)) { pos = pos.offset(side); } if(itemstack.isEmpty()) { return false; } else if(!player.canPlayerEdit(pos, side, itemstack)) { return false; } else if(world.mayPlace(Blocks.MOB_SPAWNER, pos, false, side, null)) { int meta = this.getMetadata(itemstack.getMetadata()); IBlockState iblockstate1 = Blocks.MOB_SPAWNER.getStateForPlacement(world, pos, side, xOffset, yOffset, zOffset, meta, player); if (placeBlockAt(itemstack, player, world, pos, side, xOffset, yOffset, zOffset, iblockstate1)) { world.playSound(null, pos, Blocks.MOB_SPAWNER.getSoundType().getPlaceSound(), SoundCategory.BLOCKS, (Blocks.MOB_SPAWNER.getSoundType().getVolume() + 1.0F) / 2.0F, Blocks.MOB_SPAWNER.getSoundType().getPitch() * 0.8F); player.renderBrokenItemStack(itemstack); itemstack.shrink(1); for(int i = 0; i < 100; i++) Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.45F + 0.2F * (float) Math.random(), 6); } return true; } else { return false; } }
if( blk.isReplaceable( w.getWorld(), new BlockPos( i, j, k ) ) ) if( !xf.isReplaceable( w.getWorld(), new BlockPos( i, j - 1, k ) ) )
BlockPos pos_ = pos.offset(dir); Block block_ = world.getBlockState(pos_).getBlock(); if(block_.isAir(world.getBlockState(pos_), world, pos_) || block_.isReplaceable(world, pos_) || block_ instanceof BlockFlower && !(block_ instanceof ISpecialFlower) || block_ == Blocks.DOUBLE_PLANT) { airBlocks.add(pos_);
IBlockState state = player.world.getBlockState(pos); Block block = state.getBlock(); if(block.isReplaceable(player.world, pos)) pos = pos.down(); Block block1 = state1.getBlock(); if(player.world.getWorldBorder().contains(newPos) && (block1.isAir(state1, player.world, newPos) || block1.isReplaceable(player.world, newPos))) coords.add(newPos);
@Override public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor ) { if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) ) { final TileEntity te = this.getHost().getTile(); final AEPartLocation side = this.getSide(); final BlockPos tePos = te.getPos().offset( side.getFacing() ); this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ); } }
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { // Copy of ItemBlock.onItemUse IBlockState iblockstate = world.getBlockState(pos); Block block = iblockstate.getBlock(); if (!block.isReplaceable(world, pos)) { pos = pos.offset(facing); } ItemStack stack = player.getHeldItem(hand); if (!stack.isEmpty() && player.canPlayerEdit(pos, facing, stack) && world.mayPlace(ModBlocks.buriedPetals, pos, false, facing, null)) { int i = this.getMetadata(stack.getMetadata()); IBlockState iblockstate1 = ModBlocks.buriedPetals.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, i, player); if (placeBlockAt(stack, player, world, pos, facing, hitX, hitY, hitZ, iblockstate1)) { SoundType soundtype = ModBlocks.buriedPetals.getSoundType(); world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); stack.shrink(1); } return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } }
return EnumActionResult.FAIL; } else { if (worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) { facing = EnumFacing.UP; pos = pos.down(); boolean flag = block.isReplaceable(worldIn, pos);
if( whatsThere.isReplaceable( w, hitPos ) && w.isAirBlock( hitPos ) )
@Override public void onUpdate() { super.onUpdate(); if(supertile.getWorld().isRemote || redstoneSignal > 0) return; if(ticksExisted % 30 == 0 && mana >= COST) { BlockPos pos = new BlockPos( supertile.getPos().getX() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1), supertile.getPos().getY() + RANGE, supertile.getPos().getZ() - RANGE + supertile.getWorld().rand.nextInt(RANGE * 2 + 1) ); BlockPos up = pos.up(); for(int i = 0; i < RANGE * 2; i++) { IBlockState stateAbove = supertile.getWorld().getBlockState(up); Block blockAbove = stateAbove.getBlock(); if((supertile.getWorld().isAirBlock(up) || blockAbove.isReplaceable(supertile.getWorld(), up)) && stateAbove.getMaterial() != Material.WATER && ModBlocks.flower.canPlaceBlockAt(supertile.getWorld(), up)) { EnumDyeColor color = EnumDyeColor.byMetadata(supertile.getWorld().rand.nextInt(16)); IBlockState state = ModBlocks.flower.getDefaultState().withProperty(BotaniaStateProps.COLOR, color); if(ConfigHandler.blockBreakParticles) supertile.getWorld().playEvent(2001, up, Block.getStateId(state)); supertile.getWorld().setBlockState(up, state, 1 | 2); mana -= COST; sync(); break; } up = pos; pos = pos.down(); } } }
@Override public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { BlockPos coords = burst.getBurstSourceBlockPos(); if(!entity.world.isRemote && pos.getBlockPos() != null && !coords.equals(pos.getBlockPos()) && !burst.isFake() && !isManaBlock) { BlockPos pos_ = pos.getBlockPos().offset(pos.sideHit.getOpposite()); if(entity.world.isAirBlock(pos_) || entity.world.getBlockState(pos_).getBlock().isReplaceable(entity.world, pos_)) { IBlockState state = entity.world.getBlockState(pos.getBlockPos()); TileEntity tile = entity.world.getTileEntity(pos.getBlockPos()); if(state.getPushReaction() == EnumPushReaction.NORMAL && state.getBlock() != Blocks.OBSIDIAN && state.getBlockHardness(entity.world, pos_) >= 0 && tile == null) { entity.world.destroyBlock(pos.getBlockPos(), false); entity.world.setBlockState(pos_, state, 1 | 2); } } } return dead; }
@Override public boolean collideBurst(IManaBurst burst, EntityThrowable entity, RayTraceResult pos, boolean isManaBlock, boolean dead, ItemStack stack) { BlockPos coords = burst.getBurstSourceBlockPos(); if(!entity.world.isRemote && pos.getBlockPos() != null && !coords.equals(pos.getBlockPos()) && !burst.isFake() && !isManaBlock) { BlockPos pos_ = pos.getBlockPos().offset(pos.sideHit); Block blockAt = entity.world.getBlockState(pos.getBlockPos()).getBlock(); Block blockAt_ = entity.world.getBlockState(pos_).getBlock(); if(blockAt == ModBlocks.manaFlame) entity.world.setBlockState(pos.getBlockPos(), Blocks.AIR.getDefaultState()); else if(blockAt_.isAir(entity.world.getBlockState(pos_), entity.world, pos_) || blockAt_.isReplaceable(entity.world, pos_)) { entity.world.setBlockState(pos_, ModBlocks.manaFlame.getDefaultState()); TileEntity tile = entity.world.getTileEntity(pos_); if(tile instanceof TileManaFlame) ((TileManaFlame) tile).setColor(burst.getColor()); } } return dead; }
if(filter == supertile.getWorld().getBlockState(pos_) && (blockAbove.isAir(stateAbove, supertile.getWorld(), up) || blockAbove.isReplaceable(supertile.getWorld(), up))) validPositions.add(up);
protected boolean canMakeSnow(@Nonnull World world, final @Nonnull BlockPos neighborPos, final @Nonnull IBlockState neighborState) { final BlockPos belowNeighborPos = neighborPos.down(); final Block neighborBlock = neighborState.getBlock(); return neighborBlock != Blocks.SNOW_LAYER && !(neighborBlock instanceof IFluidBlock) && !(neighborBlock instanceof BlockLiquid) && neighborBlock.isReplaceable(world, neighborPos) && world.getBlockState(belowNeighborPos).isSideSolid(world, belowNeighborPos, EnumFacing.UP); }
private boolean isValidPlantingSpot(@Nonnull World world, @Nonnull BlockPos pos) { for (int x = -1; x <= 1; x++) { for (int y = 0; y <= 1; y++) { for (int z = -1; z <= 1; z++) { if (!world.getBlockState(pos.add(x, y, z)).getBlock().isReplaceable(world, pos.add(x, y, z))) { return false; } } } } return true; }
if( blkID != null && !blkID.isReplaceable( world, pos ) ) if( blkID == null || blkID.isReplaceable( world, te_pos ) || host != null )
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { IBlockState soil = worldIn.getBlockState(pos.down()); if (this == ModBlocks.fire_lily) { return worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && (soil.getMaterial() == Material.SAND || soil.getBlock() == Blocks.NETHERRACK); } else { return worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos) && (soil.getMaterial() == Material.PACKED_ICE || soil.getMaterial() == Material.ICE); } }
if( w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos ) ) this.blocked = !w.getBlockState( tePos ).getBlock().isReplaceable( w, tePos );
IBlockState state = world.getBlockState(pos_); Block block = state.getBlock(); if(!block.isAir(state, world, pos_) && !block.isReplaceable(world, pos_) && !(block instanceof BlockFalling) && (!(block instanceof ILaputaImmobile) || ((ILaputaImmobile) block).canMove(world, pos_)) && state.getBlockHardness(world, pos_) != -1) { TileEntity tile = world.getTileEntity(pos_);
public static boolean canPlaceTree(IBlockState blockState, World world, BlockPos pos) { BlockPos downPos = pos.down(); Block block = world.getBlockState(downPos).getBlock(); return !(block.isReplaceable(world, downPos) && blockState.getMaterial().isLiquid()) && !block.isLeaves(blockState, world, downPos) && !block.isWood(world, downPos); }