public static void removeBlocksInIteration(EntityPlayer player, ItemStack stack, World world, BlockPos centerPos, Vec3i startDelta, Vec3i endDelta, Predicate<IBlockState> filter, boolean dispose) { for (BlockPos iterPos : BlockPos.getAllInBox(centerPos.add(startDelta), centerPos.add(endDelta))) { if (iterPos.equals(centerPos)) // skip original block space to avoid crash, vanilla code in the tool class will handle it continue; removeBlockWithDrops(player, stack, world, iterPos, filter, dispose); } }
@Override public void onBlockAdded(World world, BlockPos pos, IBlockState state) { super.onBlockAdded(world, pos, state); if(!world.isRemote && world.getBlockState(pos.down()).getBlock() == Blocks.IRON_BARS && world.getBlockState(pos.down(2)).getBlock() == Blocks.IRON_BARS) { world.setBlockState(pos, Blocks.AIR.getDefaultState(), 2); world.setBlockState(pos.down(), Blocks.AIR.getDefaultState(), 2); world.setBlockState(pos.down(2), Blocks.AIR.getDefaultState(), 2); EntityBlaze blaze = new EntityBlaze(world); blaze.setLocationAndAngles(pos.getX() + 0.5D, pos.getY() - 1.95D, pos.getZ() + 0.5D, 0.0F, 0.0F); blaze.deathLootTable = LOOT_TABLE; blaze.onInitialSpawn(world.getDifficultyForLocation(pos), null); world.spawnEntity(blaze); world.notifyNeighborsOfStateChange(pos, Blocks.AIR, false); world.notifyNeighborsOfStateChange(pos.down(), Blocks.AIR, false); world.notifyNeighborsOfStateChange(pos.down(2), Blocks.AIR, false); } }
@Override public BaseBiome getBiome(BlockVector2 position) { checkNotNull(position); return new BaseBiome(Biome.getIdForBiome(getWorld().getBiomeForCoordsBody(new BlockPos(position.getBlockX(), 0, position.getBlockZ())))); }
@Override public boolean shouldSideBeRendered(IBlockState state, @Nonnull IBlockAccess world, @Nonnull BlockPos pos, EnumFacing side) { if (world.getBlockState(pos.offset(side)).getBlock() == this) { return false; } return super.shouldSideBeRendered(state, world, pos, side); }
@Override public ISparkEntity getAttachedSpark() { List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class)); if(sparks.size() == 1) { Entity e = (Entity) sparks.get(0); return (ISparkEntity) e; } return null; }
public static MultiblockSet makeMultiblockSet() { Multiblock mb = new Multiblock(); for(BlockPos p : PYLON_LOCATIONS) mb.addComponent(p.up(), ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.GAIA)); for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) mb.addComponent(new BeaconComponent(new BlockPos(i - 1, 0, j - 1))); mb.addComponent(new BeaconBeamComponent(new BlockPos(0, 1, 0))); mb.setRenderOffset(new BlockPos(0, -1, 0)); return mb.makeSet(); }
public List<BlockPos> locatePylons() { List<BlockPos> list = new ArrayList(); int range = 5; IBlockState pylonState = ModBlocks.pylon.getDefaultState().withProperty(BotaniaStateProps.PYLON_VARIANT, PylonVariant.NATURA); IBlockState poolState = ModBlocks.pool.getDefaultState(); for(int i = -range; i < range + 1; i++) for(int j = -range; j < range + 1; j++) for(int k = -range; k < range + 1; k++) { BlockPos pos = new BlockPos(i, j, k); if(checkPosition(pos, pylonState, false) && checkPosition(pos.down(), poolState, true)) list.add(pos); } return list; }
@Override public boolean canSustainPlant(@Nonnull IBlockState state, @Nonnull IBlockAccess world, BlockPos pos, @Nonnull EnumFacing direction, IPlantable plantable) { EnumPlantType type = plantable.getPlantType(world, pos.down()); return type == EnumPlantType.Plains || type == EnumPlantType.Beach; }
@Override public boolean canGrow(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull IBlockState state, boolean fuckifiknow) { return world.isAirBlock(pos.up()); }
@Override public boolean canBlockStay(@Nonnull World worldIn, BlockPos pos, IBlockState state) { if (pos.getY() >= 0 && pos.getY() < 256) { IBlockState iblockstate = worldIn.getBlockState(pos.down()); return iblockstate.getBlock() == Blocks.MYCELIUM || (iblockstate.getBlock() == Blocks.DIRT && iblockstate.getValue(BlockDirt.VARIANT) == BlockDirt.DirtType.PODZOL || iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this)); } else { return false; } }
public List<ItemStack> getFilter() { List<ItemStack> filter = new ArrayList<>(); for(EnumFacing dir : EnumFacing.HORIZONTALS) { List<EntityItemFrame> frames = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1))); for(EntityItemFrame frame : frames) { EnumFacing orientation = frame.facingDirection; if(orientation == dir) filter.add(frame.getDisplayedItem()); } } return filter; }
public static boolean canEnchanterExist(World world, BlockPos pos, EnumFacing.Axis axis) { for(BlockPos obsidian : OBSIDIAN_LOCATIONS) if(world.getBlockState(pos.add(obsidian)).getBlock() != Blocks.OBSIDIAN) return false; for(BlockPos pylon : PYLON_LOCATIONS.get(axis)) if(world.getBlockState(pos.add(pylon)).getBlock() != ModBlocks.pylon || !BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(pylon).down())) return false; for(BlockPos flower : FLOWER_LOCATIONS) if(!BotaniaAPI.internalHandler.isBotaniaFlower(world, pos.add(flower))) return false; return true; }
@Override public boolean equals(Object other) { if(!(other instanceof SwapCandidate)) return false; SwapCandidate cand = (SwapCandidate) other; return coordinates.equals(cand.coordinates) && range == cand.range; }
@Override public boolean acceptBlock(BlockPos pos) { if(pos.equals(getPos().up())) return false; Block block = world.getBlockState(pos).getBlock(); TileEntity tile = world.getTileEntity(pos); return (block instanceof BlockFlower || block instanceof BlockMushroom || block instanceof BlockDoublePlant) && (tile == null || !(tile instanceof ISubTileContainer)); }
@Override public void addCollisionBoxToList(IBlockState state, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB par5AxisAlignedBB, @Nonnull List<AxisAlignedBB> stacks, Entity par7Entity, boolean isActualState) { PlatformVariant variant = state.getValue(BotaniaStateProps.PLATFORM_VARIANT); if(variant == PlatformVariant.INFRANGIBLE || variant == PlatformVariant.ABSTRUSE && par7Entity != null && par7Entity.posY > pos.getY() + 0.9 && (!(par7Entity instanceof EntityPlayer) || !par7Entity.isSneaking())) super.addCollisionBoxToList(state, world, pos, par5AxisAlignedBB, stacks, par7Entity, isActualState); }