Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public abstract class VoxelShapeMixin implements FastVoxelShapeIterable {
@Override
public Iterator<BoundingBox3dc> sable$allBoxes() {
synchronized (this) {

if(sable$boxIterator == null) {
return null;
//This is null when this mixin is relevant to little tiles
}

final long id = Thread.currentThread().threadId();
FastVoxelShapeIterator iterator = this.sable$boxIterator.get(id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,26 +275,29 @@ public static CollisionInfo collide(final Entity entity, final Vec3 collisionMot
}

final Iterator<BoundingBox3dc> iterator = ((FastVoxelShapeIterable) voxelShape).sable$allBoxes();
while (iterator.hasNext()) {
final BoundingBox3dc box = iterator.next();
box.center(center);
cubeOBB.getPosition().set(block.getX() + center.x,
block.getY() + center.y,
block.getZ() + center.z);
subLevelPose.transformPosition(cubeOBB.getPosition());
box.size(cubeOBB.getDimensions());

OrientedBoundingBox3d.sat(entityBoundsOBB, cubeOBB, mtv);

if (mtv.lengthSquared() > 0.0 && mtv.x != Double.MAX_VALUE && mtv.y != Double.MAX_VALUE && mtv.z != Double.MAX_VALUE) {
final double lengthMtv = mtv.lengthSquared();
if (lengthMtv > maxMTVLength) {
maxMTVLength = lengthMtv;
maxMTV.set(mtv);

box.move(block.getX(), block.getY(), block.getZ(), maxAABB);
maxBlockPos.set(block);
maxBlockState = state;
//This is null when this is relevant to little tiles
if(iterator != null) {
while (iterator.hasNext()) {
final BoundingBox3dc box = iterator.next();
box.center(center);
cubeOBB.getPosition().set(block.getX() + center.x,
block.getY() + center.y,
block.getZ() + center.z);
subLevelPose.transformPosition(cubeOBB.getPosition());
box.size(cubeOBB.getDimensions());

OrientedBoundingBox3d.sat(entityBoundsOBB, cubeOBB, mtv);

if (mtv.lengthSquared() > 0.0 && mtv.x != Double.MAX_VALUE && mtv.y != Double.MAX_VALUE && mtv.z != Double.MAX_VALUE) {
final double lengthMtv = mtv.lengthSquared();
if (lengthMtv > maxMTVLength) {
maxMTVLength = lengthMtv;
maxMTV.set(mtv);

box.move(block.getX(), block.getY(), block.getZ(), maxAABB);
maxBlockPos.set(block);
maxBlockState = state;
}
}
}
}
Expand Down Expand Up @@ -325,35 +328,38 @@ public static CollisionInfo collide(final Entity entity, final Vec3 collisionMot

boolean discard = false;
final Iterator<BoundingBox3dc> iterator = ((FastVoxelShapeIterable) offsetShape).sable$allBoxes();
while (iterator.hasNext()) {
final BoundingBox3dc box = iterator.next();
box.move(newPos.getX(), newPos.getY(), newPos.getZ(), offsetAABB).expand(0.001);
if (!maxAABB.intersects(offsetAABB)) {
continue;
}
//This is null when this is relevant to little tiles
if(iterator != null) {
while (iterator.hasNext()) {
final BoundingBox3dc box = iterator.next();
box.move(newPos.getX(), newPos.getY(), newPos.getZ(), offsetAABB).expand(0.001);
if (!maxAABB.intersects(offsetAABB)) {
continue;
}

compressedMinAABB.set(
maxAABB.minX * (1.0 - direction.getStepX()),
maxAABB.minY * (1.0 - direction.getStepY()),
maxAABB.minZ * (1.0 - direction.getStepZ()),
maxAABB.maxX * (1.0 - direction.getStepX()) + direction.getStepX(),
maxAABB.maxY * (1.0 - direction.getStepY()) + direction.getStepY(),
maxAABB.maxZ * (1.0 - direction.getStepZ()) + direction.getStepZ()
);

compressedOffsetAABB.set(
offsetAABB.minX * (1.0 - direction.getStepX()),
offsetAABB.minY * (1.0 - direction.getStepY()),
offsetAABB.minZ * (1.0 - direction.getStepZ()),
offsetAABB.maxX * (1.0 - direction.getStepX()) + direction.getStepX(),
offsetAABB.maxY * (1.0 - direction.getStepY()) + direction.getStepY(),
offsetAABB.maxZ * (1.0 - direction.getStepZ()) + direction.getStepZ()
);

compressedMinAABB.intersect(compressedOffsetAABB, intersection);
if (Math.abs(intersection.volume() - compressedMinAABB.volume()) < 0.01) {
discard = true;
break;
compressedMinAABB.set(
maxAABB.minX * (1.0 - direction.getStepX()),
maxAABB.minY * (1.0 - direction.getStepY()),
maxAABB.minZ * (1.0 - direction.getStepZ()),
maxAABB.maxX * (1.0 - direction.getStepX()) + direction.getStepX(),
maxAABB.maxY * (1.0 - direction.getStepY()) + direction.getStepY(),
maxAABB.maxZ * (1.0 - direction.getStepZ()) + direction.getStepZ()
);

compressedOffsetAABB.set(
offsetAABB.minX * (1.0 - direction.getStepX()),
offsetAABB.minY * (1.0 - direction.getStepY()),
offsetAABB.minZ * (1.0 - direction.getStepZ()),
offsetAABB.maxX * (1.0 - direction.getStepX()) + direction.getStepX(),
offsetAABB.maxY * (1.0 - direction.getStepY()) + direction.getStepY(),
offsetAABB.maxZ * (1.0 - direction.getStepZ()) + direction.getStepZ()
);

compressedMinAABB.intersect(compressedOffsetAABB, intersection);
if (Math.abs(intersection.volume() - compressedMinAABB.volume()) < 0.01) {
discard = true;
break;
}
}
}

Expand Down Expand Up @@ -570,6 +576,8 @@ private static boolean hasCollision(final LevelAccelerator accel, final LevelReu
}

final Iterator<BoundingBox3dc> iterator = ((FastVoxelShapeIterable) voxelShape).sable$allBoxes();
//This is null when this is relevant to little tiles
if(iterator == null) return false;
final Vector3d center = sink.center;
final Vector3d mtv = sink.mtv;

Expand Down
4 changes: 0 additions & 4 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,3 @@ reason = "Sable is out of date"
[[dependencies.sable]]
modId = "scalablelux"
type = "incompatible"

[[dependencies.sable]]
modId = "littletiles"
type = "incompatible"