Slim fence corners and some small changes on how the config gets generated
parent
481024aae3
commit
66ceb432c5
|
@ -0,0 +1,10 @@
|
|||
package xyz.pixelatedw.finalbeta;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.level.Level;
|
||||
import net.minecraft.util.maths.Box;
|
||||
|
||||
public interface IMultiBoxCollision {
|
||||
Set<Box> getCollisions(Level level, int x, int y, int z);
|
||||
}
|
|
@ -99,22 +99,17 @@ public class ModConfig {
|
|||
|
||||
this.fileConfig.load();
|
||||
|
||||
boolean save = false;
|
||||
for (Option o : OPTIONS) {
|
||||
if (!this.fileConfig.contains(o.name)) {
|
||||
this.fileConfig.add(o.name, o.defaultValue);
|
||||
this.fileConfig.setComment(o.name, o.description);
|
||||
save = true;
|
||||
} else if (!Strings.isNullOrEmpty(o.description) && this.fileConfig.contains(o.name)
|
||||
&& !this.fileConfig.containsComment(o.name)) {
|
||||
this.fileConfig.setComment(o.name, o.description);
|
||||
save = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (save) {
|
||||
this.fileConfig.load();
|
||||
}
|
||||
this.fileConfig.close();
|
||||
}
|
||||
|
||||
public static <T> Option<T> make(String name, T defaultValue, String description) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package xyz.pixelatedw.finalbeta.mixin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
|
@ -12,9 +16,10 @@ import net.minecraft.tile.FenceTile;
|
|||
import net.minecraft.tile.Tile;
|
||||
import net.minecraft.tile.material.Material;
|
||||
import net.minecraft.util.maths.Box;
|
||||
import xyz.pixelatedw.finalbeta.IMultiBoxCollision;
|
||||
|
||||
@Mixin(FenceTile.class)
|
||||
public class FenceTileMixin extends Tile {
|
||||
public class FenceTileMixin extends Tile implements IMultiBoxCollision {
|
||||
|
||||
public FenceTileMixin(int i, Material j) {
|
||||
super(i, j);
|
||||
|
@ -27,16 +32,16 @@ public class FenceTileMixin extends Tile {
|
|||
|
||||
@Inject(method = "getCollisionShape", at = @At("HEAD"), cancellable = true)
|
||||
public void getCollisionShape(Level level, int x, int y, int z, CallbackInfoReturnable<Box> cir) {
|
||||
cir.setReturnValue(createFenceBox(level, x, y, z, false));
|
||||
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 createFenceBox(level, x, y, z, true);
|
||||
return this.createVanillaFenceBox(level, x, y, z, true);
|
||||
}
|
||||
|
||||
private Box createFenceBox(Level level, int x, int y, int z, boolean isOutline) {
|
||||
private Box createVanillaFenceBox(Level level, int x, int y, int z, boolean isOutline) {
|
||||
Tile tile = ((FenceTile)(Object)this);
|
||||
|
||||
Tile xpTile = Tile.BY_ID[level.getTileId(x + 1, y, z)];
|
||||
|
@ -76,4 +81,52 @@ public class FenceTileMixin extends Tile {
|
|||
|
||||
return box;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void intersectsInLevel(Level level, int x, int y, int z, Box collision, ArrayList checks) {
|
||||
Set<Box> collisions = this.getCollisions(level, x, y, z);
|
||||
for (Box other : collisions) {
|
||||
if (other != null && collision.intersects(other)) {
|
||||
checks.add(other);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Box> getCollisions(Level level, int x, int y, int z) {
|
||||
Set<Box> collisions = new HashSet<Box>();
|
||||
|
||||
Tile xpTile = Tile.BY_ID[level.getTileId(x + 1, y, z)];
|
||||
Tile xnTile = Tile.BY_ID[level.getTileId(x - 1, y, z)];
|
||||
Tile zpTile = Tile.BY_ID[level.getTileId(x, y, z + 1)];
|
||||
Tile znTile = Tile.BY_ID[level.getTileId(x, y, z - 1)];
|
||||
|
||||
boolean xpCheck = xpTile != null && (xpTile.isFullCube() || xpTile.id == Tile.FENCE.id);
|
||||
boolean xnCheck = xnTile != null && (xnTile.isFullCube() || xnTile.id == Tile.FENCE.id);
|
||||
boolean zpCheck = zpTile != null && (zpTile.isFullCube() || zpTile.id == Tile.FENCE.id);
|
||||
boolean znCheck = znTile != null && (znTile.isFullCube() || znTile.id == Tile.FENCE.id);
|
||||
|
||||
boolean eastCheck = level.getMaterial(x + 1, y, z).isSolid() && xpCheck;
|
||||
boolean westCheck = level.getMaterial(x - 1, y, z).isSolid() && xnCheck;
|
||||
boolean southCheck = level.getMaterial(x, y, z + 1).isSolid() && zpCheck;
|
||||
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.0F, z + 0.625f));
|
||||
}
|
||||
|
||||
if (westCheck) {
|
||||
collisions.add(Box.create(x + 0.0f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.0F, z + 0.625f));
|
||||
}
|
||||
|
||||
if (northCheck) {
|
||||
collisions.add(Box.create(x + 0.375f, y + 0.0f, z + 0.0f, x + 0.625f, y + 1.0F, z + 0.625f));
|
||||
}
|
||||
|
||||
if (southCheck) {
|
||||
collisions.add(Box.create(x + 0.375f, y + 0.0f, z + 0.375f, x + 0.625f, y + 1.0F, z + 1.0f));
|
||||
}
|
||||
|
||||
return collisions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class MinecraftMixin {
|
|||
public void createDisplay() throws LWJGLException {
|
||||
// Why the fuck is this even a thing ? What was its intended purpose ? I NEED TO KNOW
|
||||
Minecraft.field_2800 = null;
|
||||
Display.create(new PixelFormat(0, 24, 0));
|
||||
Display.create(new PixelFormat().withDepthBits(24));
|
||||
}
|
||||
|
||||
@Inject(method = "loadSoundFromDir", at = @At("HEAD"))
|
||||
|
|
Loading…
Reference in New Issue