Fixed the slim fence config not being used
parent
8a0d5b3c4d
commit
39f49c5a9c
|
@ -17,6 +17,7 @@ import net.minecraft.tile.Tile;
|
||||||
import net.minecraft.tile.material.Material;
|
import net.minecraft.tile.material.Material;
|
||||||
import net.minecraft.util.maths.Box;
|
import net.minecraft.util.maths.Box;
|
||||||
import xyz.pixelatedw.finalbeta.IMultiBoxCollision;
|
import xyz.pixelatedw.finalbeta.IMultiBoxCollision;
|
||||||
|
import xyz.pixelatedw.finalbeta.ModConfig;
|
||||||
|
|
||||||
@Mixin(FenceTile.class)
|
@Mixin(FenceTile.class)
|
||||||
public class FenceTileMixin extends Tile implements IMultiBoxCollision {
|
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)
|
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||||
public void getCollisionShape(Level level, int x, int y, int z, CallbackInfoReturnable<Box> cir) {
|
public void getCollisionShape(Level level, int x, int y, int z, CallbackInfoReturnable<Box> 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
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public Box getOutlineShape(Level level, int x, int y, int z) {
|
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) {
|
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 southCheck = level.getMaterial(x, y, z + 1).isSolid() && zpCheck;
|
||||||
boolean northCheck = level.getMaterial(x, y, z - 1).isSolid() && znCheck;
|
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.minX = westCheck ? 0 : 0.375f;
|
||||||
tile.minY = 0.0;
|
tile.minY = 0.0;
|
||||||
|
@ -84,10 +90,12 @@ public class FenceTileMixin extends Tile implements IMultiBoxCollision {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void intersectsInLevel(Level level, int x, int y, int z, Box collision, ArrayList checks) {
|
public void intersectsInLevel(Level level, int x, int y, int z, Box collision, ArrayList checks) {
|
||||||
Set<Box> collisions = this.getCollisions(level, x, y, z);
|
if(ModConfig.FENCE_SLIM_HITBOX.get()) {
|
||||||
for (Box other : collisions) {
|
Set<Box> collisions = this.getCollisions(level, x, y, z);
|
||||||
if (other != null && collision.intersects(other)) {
|
for (Box other : collisions) {
|
||||||
checks.add(other);
|
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;
|
boolean northCheck = level.getMaterial(x, y, z - 1).isSolid() && znCheck;
|
||||||
|
|
||||||
if (eastCheck) {
|
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) {
|
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) {
|
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) {
|
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()) {
|
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;
|
return collisions;
|
||||||
|
|
Loading…
Reference in New Issue