diff --git a/src/main/java/xyz/pixelatedw/finalbeta/mixin/FenceTileMixin.java b/src/main/java/xyz/pixelatedw/finalbeta/mixin/FenceTileMixin.java index 68aad4e..6cb6d2c 100644 --- a/src/main/java/xyz/pixelatedw/finalbeta/mixin/FenceTileMixin.java +++ b/src/main/java/xyz/pixelatedw/finalbeta/mixin/FenceTileMixin.java @@ -17,6 +17,7 @@ import net.minecraft.tile.Tile; import net.minecraft.tile.material.Material; import net.minecraft.util.maths.Box; import xyz.pixelatedw.finalbeta.IMultiBoxCollision; +import xyz.pixelatedw.finalbeta.ModConfig; @Mixin(FenceTile.class) public class FenceTileMixin extends Tile implements IMultiBoxCollision { @@ -32,13 +33,18 @@ public class FenceTileMixin extends Tile implements IMultiBoxCollision { @Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true) public void getCollisionShape(Level level, int x, int y, int z, CallbackInfoReturnable cir) { - cir.setReturnValue(this.createVanillaFenceBox(level, x, y, z, false)); + if(ModConfig.FENCE_SLIM_HITBOX.get()) { + cir.setReturnValue(this.createVanillaFenceBox(level, x, y, z, false)); + } } @Override @Environment(EnvType.CLIENT) public Box getOutlineShape(Level level, int x, int y, int z) { - return this.createVanillaFenceBox(level, x, y, z, true); + if(ModConfig.FENCE_SLIM_HITBOX.get()) { + return this.createVanillaFenceBox(level, x, y, z, true); + } + return super.getOutlineShape(level, x, y, z); } private Box createVanillaFenceBox(Level level, int x, int y, int z, boolean isOutline) { @@ -59,7 +65,7 @@ public class FenceTileMixin extends Tile implements IMultiBoxCollision { boolean southCheck = level.getMaterial(x, y, z + 1).isSolid() && zpCheck; boolean northCheck = level.getMaterial(x, y, z - 1).isSolid() && znCheck; - Box box = Box.create(westCheck ? 0 : 0.375f, 0.0f, northCheck ? 0.0f : 0.375f, eastCheck ? 1.0f : 0.625f, 1.0F, southCheck ? 1.0f : 0.625f); + Box box = Box.getOrCreate(westCheck ? 0 : 0.375f, 0.0f, northCheck ? 0.0f : 0.375f, eastCheck ? 1.0f : 0.625f, 1.0F, southCheck ? 1.0f : 0.625f); tile.minX = westCheck ? 0 : 0.375f; tile.minY = 0.0; @@ -84,10 +90,12 @@ public class FenceTileMixin extends Tile implements IMultiBoxCollision { @Override public void intersectsInLevel(Level level, int x, int y, int z, Box collision, ArrayList checks) { - Set collisions = this.getCollisions(level, x, y, z); - for (Box other : collisions) { - if (other != null && collision.intersects(other)) { - checks.add(other); + if(ModConfig.FENCE_SLIM_HITBOX.get()) { + Set collisions = this.getCollisions(level, x, y, z); + for (Box other : collisions) { + if (other != null && collision.intersects(other)) { + checks.add(other); + } } } } @@ -112,23 +120,23 @@ public class FenceTileMixin extends Tile implements IMultiBoxCollision { boolean northCheck = level.getMaterial(x, y, z - 1).isSolid() && znCheck; if (eastCheck) { - collisions.add(Box.create(x + 0.375f, y + 0.0f, z + 0.375f, x + 1.0f, y + 1.5F, z + 0.625f)); + collisions.add(Box.getOrCreate(x + 0.375f, y + 0.0f, z + 0.375f, x + 1.0f, y + 1.5F, z + 0.625f)); } if (westCheck) { - collisions.add(Box.create(x + 0.0f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 0.625f)); + collisions.add(Box.getOrCreate(x + 0.0f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 0.625f)); } if (northCheck) { - collisions.add(Box.create(x + 0.375f, y + 0.0f, z + 0.0f, x + 0.625f, y + 1.5F, z + 0.625f)); + collisions.add(Box.getOrCreate(x + 0.375f, y + 0.0f, z + 0.0f, x + 0.625f, y + 1.5F, z + 0.625f)); } if (southCheck) { - collisions.add(Box.create(x + 0.375f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 1.0f)); + collisions.add(Box.getOrCreate(x + 0.375f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 1.0f)); } if (collisions.isEmpty()) { - collisions.add(Box.create(x + 0.375f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 0.625f)); + collisions.add(Box.getOrCreate(x + 0.375f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.5F, z + 0.625f)); } return collisions;