Search in sources :

Example 1 with BitSetVoxelSet

use of net.minecraft.util.shape.BitSetVoxelSet in project roadrunner by MaxNeedsSnacks.

the class VoxelSetHash method hashCode.

@Override
public int hashCode(VoxelSet o) {
    VoxelSetAccess generalAccess = (VoxelSetAccess) o;
    int result = generalAccess.getXSize();
    result = 31 * result + generalAccess.getYSize();
    result = 31 * result + generalAccess.getZSize();
    if (o instanceof CroppedVoxelSet) {
        CroppedVoxelSetAccess access = access((CroppedVoxelSet) o);
        result = 31 * result + access.getXMin();
        result = 31 * result + access.getYMin();
        result = 31 * result + access.getZMin();
        result = 31 * result + access.getXMax();
        result = 31 * result + access.getYMax();
        result = 31 * result + access.getZMax();
        result = 31 * result + hashCode(access.getParent());
        return result;
    } else if (o instanceof BitSetVoxelSet) {
        BitSetVSAccess access = access((BitSetVoxelSet) o);
        result = 31 * result + access.getXMin();
        result = 31 * result + access.getYMin();
        result = 31 * result + access.getZMin();
        result = 31 * result + access.getXMax();
        result = 31 * result + access.getYMax();
        result = 31 * result + access.getZMax();
        result = 31 * result + Objects.hashCode(access.getStorage());
        return result;
    } else {
        return 31 * result + Objects.hashCode(o);
    }
}
Also used : CroppedVoxelSet(net.minecraft.util.shape.CroppedVoxelSet) CroppedVoxelSetAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.CroppedVoxelSetAccess) VoxelSetAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.VoxelSetAccess) BitSetVSAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.BitSetVSAccess) CroppedVoxelSetAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.CroppedVoxelSetAccess) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet)

Example 2 with BitSetVoxelSet

use of net.minecraft.util.shape.BitSetVoxelSet in project roadrunner by MaxNeedsSnacks.

the class VoxelSetHash method equals.

@Override
public boolean equals(VoxelSet a, VoxelSet b) {
    if (a == b) {
        return true;
    } else if (a == null || b == null) {
        return false;
    } else if (a.getClass() != b.getClass()) {
        return false;
    }
    VoxelSetAccess genAccessA = (VoxelSetAccess) a;
    VoxelSetAccess genAccessB = (VoxelSetAccess) b;
    if (genAccessA.getXSize() != genAccessB.getXSize() || genAccessA.getYSize() != genAccessB.getYSize() || genAccessA.getZSize() != genAccessB.getZSize()) {
        return false;
    }
    if (a instanceof CroppedVoxelSet) {
        CroppedVoxelSetAccess accessA = access((CroppedVoxelSet) a);
        CroppedVoxelSetAccess accessB = access((CroppedVoxelSet) b);
        return accessA.getXMax() == accessB.getXMax() && accessA.getYMax() == accessB.getYMax() && accessA.getZMax() == accessB.getZMax() && accessA.getXMin() == accessB.getXMin() && accessA.getYMin() == accessB.getYMin() && accessA.getZMin() == accessB.getZMin() && equals(accessA.getParent(), accessB.getParent());
    } else if (a instanceof BitSetVoxelSet) {
        BitSetVSAccess accessA = access((BitSetVoxelSet) a);
        BitSetVSAccess accessB = access((BitSetVoxelSet) b);
        return accessA.getXMax() == accessB.getXMax() && accessA.getYMax() == accessB.getYMax() && accessA.getZMax() == accessB.getZMax() && accessA.getXMin() == accessB.getXMin() && accessA.getYMin() == accessB.getYMin() && accessA.getZMin() == accessB.getZMin() && accessA.getStorage().equals(accessB.getStorage());
    } else {
        return a.equals(b);
    }
}
Also used : CroppedVoxelSet(net.minecraft.util.shape.CroppedVoxelSet) CroppedVoxelSetAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.CroppedVoxelSetAccess) VoxelSetAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.VoxelSetAccess) BitSetVSAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.BitSetVSAccess) CroppedVoxelSetAccess(me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.CroppedVoxelSetAccess) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet)

Example 3 with BitSetVoxelSet

use of net.minecraft.util.shape.BitSetVoxelSet in project Biome-Makeover by Lemonszz.

the class WaterTreeFeature method placeLogsAndLeaves.

private VoxelSet placeLogsAndLeaves(WorldAccess world, BlockBox box, Set<BlockPos> logs, Set<BlockPos> leaves) {
    List<Set<BlockPos>> list = Lists.newArrayList();
    VoxelSet voxelSet = new BitSetVoxelSet(box.getBlockCountX(), box.getBlockCountY(), box.getBlockCountZ());
    for (int j = 0; j < 6; ++j) {
        list.add(Sets.newHashSet());
    }
    BlockPos.Mutable mutable = new BlockPos.Mutable();
    Iterator var9 = Lists.newArrayList(leaves).iterator();
    BlockPos blockPos2;
    while (var9.hasNext()) {
        blockPos2 = (BlockPos) var9.next();
        if (box.contains(blockPos2)) {
            voxelSet.set(blockPos2.getX() - box.minX, blockPos2.getY() - box.minY, blockPos2.getZ() - box.minZ, true, true);
        }
    }
    var9 = Lists.newArrayList(logs).iterator();
    while (var9.hasNext()) {
        blockPos2 = (BlockPos) var9.next();
        if (box.contains(blockPos2)) {
            voxelSet.set(blockPos2.getX() - box.minX, blockPos2.getY() - box.minY, blockPos2.getZ() - box.minZ, true, true);
        }
        Direction[] var11 = Direction.values();
        int var12 = var11.length;
        for (int var13 = 0; var13 < var12; ++var13) {
            Direction direction = var11[var13];
            mutable.set(blockPos2, direction);
            if (!logs.contains(mutable)) {
                BlockState blockState = world.getBlockState(mutable);
                if (blockState.contains(Properties.DISTANCE_1_7)) {
                    list.get(0).add(mutable.toImmutable());
                    setBlockStateWithoutUpdatingNeighbors(world, mutable, blockState.with(Properties.DISTANCE_1_7, 1));
                    if (box.contains(mutable)) {
                        voxelSet.set(mutable.getX() - box.minX, mutable.getY() - box.minY, mutable.getZ() - box.minZ, true, true);
                    }
                }
            }
        }
    }
    for (int k = 1; k < 6; ++k) {
        Set<BlockPos> set = list.get(k - 1);
        Set<BlockPos> set2 = list.get(k);
        Iterator var25 = set.iterator();
        while (var25.hasNext()) {
            BlockPos blockPos3 = (BlockPos) var25.next();
            if (box.contains(blockPos3)) {
                voxelSet.set(blockPos3.getX() - box.minX, blockPos3.getY() - box.minY, blockPos3.getZ() - box.minZ, true, true);
            }
            Direction[] var27 = Direction.values();
            int var28 = var27.length;
            for (int var16 = 0; var16 < var28; ++var16) {
                Direction direction2 = var27[var16];
                mutable.set(blockPos3, direction2);
                if (!set.contains(mutable) && !set2.contains(mutable)) {
                    BlockState blockState2 = world.getBlockState(mutable);
                    if (blockState2.contains(Properties.DISTANCE_1_7)) {
                        int l = blockState2.get(Properties.DISTANCE_1_7);
                        if (l > k + 1) {
                            BlockState blockState3 = blockState2.with(Properties.DISTANCE_1_7, k + 1);
                            setBlockStateWithoutUpdatingNeighbors(world, mutable, blockState3);
                            if (box.contains(mutable)) {
                                voxelSet.set(mutable.getX() - box.minX, mutable.getY() - box.minY, mutable.getZ() - box.minZ, true, true);
                            }
                            set2.add(mutable.toImmutable());
                        }
                    }
                }
            }
        }
    }
    return voxelSet;
}
Also used : VoxelSet(net.minecraft.util.shape.VoxelSet) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet) VoxelSet(net.minecraft.util.shape.VoxelSet) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet) Direction(net.minecraft.util.math.Direction) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet)

Example 4 with BitSetVoxelSet

use of net.minecraft.util.shape.BitSetVoxelSet in project SpoornPink by spoorn.

the class AbstractSPTree method placeLogsAndLeaves.

/**
 * Copy vanilla's from {@link TreeFeature}.  This updates neighbor block states for the changed blocks and prevents
 * leaves from decaying if they are near logs.
 */
private static VoxelSet placeLogsAndLeaves(WorldAccess world, BlockBox box, Set<BlockPos> trunkPositions) {
    ArrayList<Set<BlockPos>> list = Lists.newArrayList();
    BitSetVoxelSet voxelSet = new BitSetVoxelSet(box.getBlockCountX(), box.getBlockCountY(), box.getBlockCountZ());
    int i = 6;
    for (int j = 0; j < 6; ++j) {
        list.add(Sets.newHashSet());
    }
    BlockPos.Mutable mutable = new BlockPos.Mutable();
    for (BlockPos blockPos : Lists.newArrayList(trunkPositions)) {
        if (box.contains(blockPos)) {
            ((VoxelSet) voxelSet).set(blockPos.getX() - box.getMinX(), blockPos.getY() - box.getMinY(), blockPos.getZ() - box.getMinZ());
        }
        for (Direction direction : Direction.values()) {
            BlockState blockState;
            mutable.set((Vec3i) blockPos, direction);
            if (trunkPositions.contains(mutable) || !(blockState = world.getBlockState(mutable)).contains(Properties.DISTANCE_1_7))
                continue;
            ((Set) list.get(0)).add(mutable.toImmutable());
            setBlockStateWithoutUpdatingNeighbors(world, mutable, (BlockState) blockState.with(Properties.DISTANCE_1_7, 1));
            if (!box.contains(mutable))
                continue;
            ((VoxelSet) voxelSet).set(mutable.getX() - box.getMinX(), mutable.getY() - box.getMinY(), mutable.getZ() - box.getMinZ());
        }
    }
    for (int k = 1; k < 6; ++k) {
        Set<BlockPos> set = list.get(k - 1);
        Set<BlockPos> set2 = list.get(k);
        for (BlockPos blockPos2 : set) {
            if (box.contains(blockPos2)) {
                ((VoxelSet) voxelSet).set(blockPos2.getX() - box.getMinX(), blockPos2.getY() - box.getMinY(), blockPos2.getZ() - box.getMinZ());
            }
            for (Direction direction2 : Direction.values()) {
                int l;
                BlockState blockState2;
                mutable.set((Vec3i) blockPos2, direction2);
                if (set.contains(mutable) || set2.contains(mutable) || !(blockState2 = world.getBlockState(mutable)).contains(Properties.DISTANCE_1_7) || (l = blockState2.get(Properties.DISTANCE_1_7).intValue()) <= k + 1)
                    continue;
                BlockState blockState3 = (BlockState) blockState2.with(Properties.DISTANCE_1_7, k + 1);
                setBlockStateWithoutUpdatingNeighbors(world, mutable, blockState3);
                if (box.contains(mutable)) {
                    ((VoxelSet) voxelSet).set(mutable.getX() - box.getMinX(), mutable.getY() - box.getMinY(), mutable.getZ() - box.getMinZ());
                }
                set2.add(mutable.toImmutable());
            }
        }
    }
    return voxelSet;
}
Also used : BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet) VoxelSet(net.minecraft.util.shape.VoxelSet) Set(java.util.Set) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet) VoxelSet(net.minecraft.util.shape.VoxelSet) BlockState(net.minecraft.block.BlockState) BlockPos(net.minecraft.util.math.BlockPos) BitSetVoxelSet(net.minecraft.util.shape.BitSetVoxelSet) Direction(net.minecraft.util.math.Direction)

Aggregations

BitSetVoxelSet (net.minecraft.util.shape.BitSetVoxelSet)4 BitSetVSAccess (me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.BitSetVSAccess)2 CroppedVoxelSetAccess (me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.CroppedVoxelSetAccess)2 VoxelSetAccess (me.jellysquid.mods.lithium.mixin.shapes.side_shape_cache.VoxelSetAccess)2 BlockState (net.minecraft.block.BlockState)2 BlockPos (net.minecraft.util.math.BlockPos)2 Direction (net.minecraft.util.math.Direction)2 CroppedVoxelSet (net.minecraft.util.shape.CroppedVoxelSet)2 VoxelSet (net.minecraft.util.shape.VoxelSet)2 Set (java.util.Set)1