@Override public boolean onBlockStartBreak(ItemStack stack, BlockPos pos, EntityPlayer player) { World world = player.world; Material mat = world.getBlockState(pos).getMaterial(); if (!ToolCommons.materialsShovel.contains(mat)) return false; RayTraceResult block = ToolCommons.raytraceFromEntity(world, player, true, 10); if (block == null) return false; Block blk = world.getBlockState(pos).getBlock(); if(blk instanceof BlockFalling) ToolCommons.removeBlocksInIteration(player, stack, world, pos, new Vec3i(0, -12, 0), new Vec3i(1, 12, 1), state -> state.getBlock() == blk, false); return false; }
@Override public Vec3i getArea() { if (area == null) { int basisArea = 5; if (Config.ringFarms) { basisArea = basisArea + 1 + Config.ringSize * 2; } area = new Vec3i(basisArea + Config.planterExtend, 13, basisArea + Config.planterExtend); } return area; }
@Override public Vec3i getArea() { if (area == null) { area = new Vec3i(7 + allowedExtent * 2, 13, 7 + allowedExtent * 2); } return area; }
Territory(int x, int y, int z, boolean dominant) { this.area = new Vec3i(x, y, z); this.dominant = dominant; }
@Override public Vec3i offsetToCenter() { return new Vec3i(4, 1, 4); } }
@Override public Vec3i offsetToCenter() { return new Vec3i(5, 4, 5); } }
@Override public Vec3i offsetToCenter() { return new Vec3i(4, 1, 4); } }
@Override public Vec3i offsetToCenter() { return new Vec3i(5, 4, 5); } }
@Override public Vec3i offsetToCenter() { return new Vec3i(1, 1, 1); } }
/** * @return the actual inner size. */ public Vec3i getInnerSize() { return LocationHelpers.subtract(getSize(), new Vec3i(1, 1, 1)); }
private static boolean hasRoom(World world, BlockPos pos, int expectedGirth, int expectedHeight) { Vec3i area = new Vec3i(expectedGirth, expectedHeight + 1, expectedGirth); return checkArea(world, pos.up(), area); }
public @Nonnull Vec3i getOffsetFromMaster() { if (offsetToMaster == null) { return new Vec3i(0, 0, 0); } return new BlockPos(-offsetToMaster.getX(), -offsetToMaster.getY(), -offsetToMaster.getZ()); }
@Override public Vec3i getOffset() { if (offset == null) { Vec3i area = getArea(); offset = new Vec3i(-area.getX() / 2, -2, -area.getZ() / 2); } return offset; }
@Override public Vec3i getOffset() { if (offset == null) { Vec3i area = getArea(); offset = new Vec3i(-area.getX() / 2, -2, -area.getZ() / 2); } return offset; }
@Override @SideOnly(Side.CLIENT) public AxisAlignedBB getRenderBoundingBox() { return new AxisAlignedBB(getPos().subtract(new Vec3i(3, 3, 3)), getPos().add(3, 6, 3)); }
private static Tuple<short[], Integer> removeTopAirOnlyLayers(int xSize, int ySize, int zSize, short[] templateRuleData) { Vec3i size = new Vec3i(xSize, ySize, zSize); for (int y = ySize - 1; y >= 0; y--) { if (!areAllAirInLayer(size, y, templateRuleData)) { if (y == ySize - 1) { return new Tuple<>(templateRuleData, ySize); } return new Tuple<>(Arrays.copyOf(templateRuleData, xSize * (y + 1) * zSize), y + 1); } } return new Tuple<>(new short[0], 0); }
private static boolean areAllAirInLayer(Vec3i size, int yLayer, short[] templateRuleData) { for (int z = 0; z < size.getZ(); z++) { for (int x = 0; x < size.getX(); x++) { int index = StructureTemplate.getIndex(new Vec3i(x, yLayer, z), size); if (templateRuleData[index] != 0) { return false; } } } return true; } }
public NonNullList<ItemStack> getResourceList() { if (resourceList == null) { NonNullList<ItemStack> stacks = NonNullList.create(); MathUtils.getAllVecsInBox(Vec3i.NULL_VECTOR, new Vec3i(size.getX() - 1, size.getY() - 1, size.getZ() - 1)) .forEach(pos -> getRuleAt(pos).ifPresent(r -> r.addResources(stacks))); resourceList = InventoryTools.compactStackList(stacks); } return resourceList; }
public static void generateSphere(World world, BlockPos center, int radius, ITreeBlockType block, EnumReplaceMode replace) { Vec3i start = new Vec3i(center.getX() - radius, center.getY() - radius, center.getZ() - radius); Vec3i area = new Vec3i(radius * 2 + 1, radius * 2 + 1, radius * 2 + 1); for (int x = start.getX(); x < start.getX() + area.getX(); x++) { for (int y = start.getY() + area.getY() - 1; y >= start.getY(); y--) { // generating top-down is faster for lighting calculations for (int z = start.getZ(); z < start.getZ() + area.getZ(); z++) { if (center.getDistance(x, y, z) <= radius + 0.01) { addBlock(world, new BlockPos(x, y, z), block, replace); } } } } }