private List<BlockPos> getCoordsToPut(BlockPos pos) { List<BlockPos> possibleCoords = new ArrayList<>(); int range = 4; int rangeY = 4; for (BlockPos bPos : BlockPos.getAllInBox(pos.add(-range, -rangeY, -range), pos.add(range, rangeY, range))) { IBlockState state = world.getBlockState(bPos); Block block = state.getBlock(); if(block.isReplaceableOreGen(state, world, bPos, BlockStateMatcher.forBlock(Blocks.STONE))) possibleCoords.add(bPos); } Collections.shuffle(possibleCoords, rand); return possibleCoords.stream().limit(64).collect(Collectors.toList()); }
private BlockPos getCoordsToPut() { List<BlockPos> possibleCoords = new ArrayList<>(); for(BlockPos pos : BlockPos.getAllInBox(getPos().add(-RANGE, -RANGE_Y, -RANGE), getPos().add(RANGE, RANGE_Y, RANGE))) { IBlockState state = supertile.getWorld().getBlockState(pos); if(state.getBlock().isReplaceableOreGen(state, supertile.getWorld(), pos, getReplaceMatcher())) possibleCoords.add(pos); } if(possibleCoords.isEmpty()) return null; return possibleCoords.get(supertile.getWorld().rand.nextInt(possibleCoords.size())); }
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); } }
private BlockPos getCoordsToPut() { List<BlockPos> possibleCoords = new ArrayList<>(); int range = getRange(); int rangeY = getRangeY(); BlockStateMatcher matcher = BlockStateMatcher.forBlock(Blocks.STONE); for(BlockPos pos : BlockPos.getAllInBox(getPos().add(-range, -rangeY, -range), getPos().add(range, rangeY, range))) { IBlockState state = supertile.getWorld().getBlockState(pos); if(state.getBlock().isReplaceableOreGen(state, supertile.getWorld(), pos, matcher)) possibleCoords.add(pos); } if(possibleCoords.isEmpty()) return null; return possibleCoords.get(supertile.getWorld().rand.nextInt(possibleCoords.size())); }
public void doHighlight(World world, BlockPos pos, int range, long seedxor) { Botania.proxy.setWispFXDepthTest(false); for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) { IBlockState state = world.getBlockState(pos_); if(Item.getItemFromBlock(state.getBlock()) == Items.AIR) continue; ItemStack orestack = new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)); for(int id : OreDictionary.getOreIDs(orestack)) { String s = OreDictionary.getOreName(id); if(s.matches("^ore[A-Z].+")) { Random rand = new Random(s.hashCode() ^ seedxor); Botania.proxy.wispFX(pos_.getX() + world.rand.nextFloat(), pos_.getY() + world.rand.nextFloat(), pos_.getZ() + world.rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), rand.nextFloat(), 0.25F, 0F, 8); break; } } } Botania.proxy.setWispFXDepthTest(true); }
/** * Ticks this block swapper, allowing it to make an action during * this game tick. This method should return "false" when the swapper * has finished operation and should be removed from the world. * @return true if the swapper should continue to exist, false if it * should be removed. */ public boolean tick() { if(++ticksExisted % 20 == 0) { for(BlockPos pos : BlockPos.getAllInBox(startCoords.add(-RANGE, 0, -RANGE), startCoords.add(RANGE, 0, RANGE))) { if(world.getBlockState(pos) == stateToSet) tickBlock(pos); } } // This swapper should exist for 80 ticks return ticksExisted < 80; }
List<BlockPos> coords = new ArrayList<>(); for(BlockPos pos : BlockPos.getAllInBox(srcPos.add(-range, -rangeY, -range), srcPos.add(range, rangeY, range))) { Block block = world.getBlockState(pos).getBlock(); if(block instanceof IHornHarvestable
BlockPos pos = supertile.getPos(); for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-RANGE, 0, -RANGE), pos.add(RANGE, RANGE_Y, RANGE))) { if(supertile.getWorld().getBlockState(pos_).getMaterial() == Material.LEAVES) { boolean exposed = false;
@Nonnull @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xs, float ys, float zs) { TileEntity tileAt = world.getTileEntity(pos); if(tileAt != null && (tileAt instanceof IManaPool || tileAt instanceof IManaCollector)) { boolean pool = tileAt instanceof IManaPool; Actuator act = pool ? Actuator.functionalActuator : Actuator.generatingActuator; int range = pool ? SubTileFunctional.LINK_RANGE : SubTileGenerating.LINK_RANGE; for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-range, -range, -range), pos.add(range, range, range))) { if(pos_.distanceSq(pos) > range * range) continue; TileEntity tile = world.getTileEntity(pos_); if(tile instanceof ISubTileContainer) { SubTileEntity subtile = ((ISubTileContainer) tile).getSubTile(); if(act.actuate(subtile, tileAt)) { Vector3 orig = new Vector3(pos_.getX() + 0.5, pos_.getY() + 0.5, pos_.getZ() + 0.5); Vector3 end = new Vector3(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); ItemTwigWand.doParticleBeam(world, orig, end); } } } if(player.world.isRemote) player.swingArm(hand); return EnumActionResult.SUCCESS; } return EnumActionResult.PASS; }
for(BlockPos pos : BlockPos.getAllInBox(getPos().add(-RANGE, -RANGE_Y, -RANGE), getPos().add(RANGE, RANGE_Y, RANGE))) { TileEntity tile = supertile.getWorld().getTileEntity(pos); Block block = supertile.getWorld().getBlockState(pos).getBlock();
if(stackItem instanceof ItemBlock || stackItem instanceof ItemBlockSpecial || stackItem instanceof ItemRedstone || stackItem instanceof IFlowerPlaceable) { if(!scanned) { for(BlockPos pos_ : BlockPos.getAllInBox(pos.add(-rangePlace, -rangePlaceY, -rangePlace), pos.add(rangePlace, rangePlaceY, rangePlace))) { IBlockState stateAbove = supertile.getWorld().getBlockState(pos_.up()); Block blockAbove = stateAbove.getBlock();
/** * Wrapper around BlockPos.getAllInBox() with an AABB * Note that this is inclusive of all positions in the AABB! */ public static Iterable<BlockPos> getPositionsFromBox(AxisAlignedBB box) { return BlockPos.getAllInBox(new BlockPos(box.minX, box.minY, box.minZ), new BlockPos(box.maxX, box.maxY, box.maxZ)); }
private void generateBlob(World world, Random rand, BlockPos position) { int sizeX = this.baseRadius + rand.nextInt(2); int sizeY = this.baseRadius + rand.nextInt(2); int sizeZ = this.baseRadius + rand.nextInt(2); double range = (sizeX + sizeY + sizeZ) * 0.333 + 0.5; for (BlockPos pos : BlockPos.getAllInBox(position.add(-sizeX, -sizeY, -sizeZ), position.add(sizeX, sizeY, sizeZ))) { if (pos.distanceSq(position) <= range * range) { world.setBlockState(pos, this.state, 4); } } } }
/** * The actual check. It inputs the radius and feeds it to the sphere shape method. After it gets the block position map it scans every block in that map. Then returns depending if the match triggers. */ private static boolean torchCheck(World world, BlockPos pos) { for (BlockPos location : BlockPos.getAllInBox(pos.add(-8, -8, -8), pos.add(8, 8, 8))) { if (blackList.contains(world.getBlockState(location).getBlock())) { return true; } } return false; } }
/** * The actual check. It inputs the radius and feeds it to the sphere shape method. After it gets the block position map it scans every block in that map. Then returns depending if the match triggers. */ private static boolean torchCheck(World world, BlockPos pos) { for (BlockPos location : BlockPos.getAllInBox(pos.add(-8, -8, -8), pos.add(8, 8, 8))) { if (blackList.contains(world.getBlockState(location).getBlock())) { return true; } } return false; } /* SPAWN CONDITIONS */
@Override public Iterable<BlockPos> getCandidates(EntityPlayer player, BlockPos pos, EnumFacing side) { if (side.getAxisDirection() == AxisDirection.NEGATIVE) { side = side.getOpposite(); } Vec3i offset = side.getDirectionVec(); return filteredIterable(Sets.newHashSet(BlockPos.getAllInBox(NEG_ONE.add(offset).add(pos), ONE.subtract(offset).add(pos))), player.world, player.world.getBlockState(pos)); }
for (BlockPos pos : BlockPos.getAllInBox(basePos.add(-range, -range, -range), basePos.add(range, range, range))) { if(entity.world.getTileEntity(pos) instanceof IManaReceiver) { TileEntity tile = entity.world.getTileEntity(pos);
public static void extinguishNearby(World world, EntityPlayer player) { for (BlockPos pos : BlockPos.getAllInBox(new BlockPos(player).add(-1, -1, -1), new BlockPos(player).add(1, 1, 1))) { if (world.getBlockState(pos).getBlock() == Blocks.FIRE && PlayerHelper.hasBreakPermission(((EntityPlayerMP) player), pos)) { world.setBlockToAir(pos); } } }
@Override public boolean shouldEscapeWaterFast() { int radiusXZ = 4; for(BlockPos pos : BlockPos.getAllInBox(MathHelper.floor(this.posX - radiusXZ), MathHelper.floor(this.posY), MathHelper.floor(this.posZ - radiusXZ), MathHelper.ceil(this.posX + radiusXZ), MathHelper.ceil(this.posY), MathHelper.ceil(this.posZ + radiusXZ))) { if(!world.getBlockState(pos).getMaterial().isLiquid()) { return false; } } return false; }
@Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (worldIn.isAreaLoaded(pos.add(-5, -5, -5), pos.add(5, 5, 5))) { for (BlockPos blockpos : BlockPos.getAllInBox(pos.add(-4, -4, -4), pos.add(4, 4, 4))) { IBlockState iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos)) { iblockstate.getBlock().beginLeavesDecay(iblockstate, worldIn, blockpos); } } } }