diff --git a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java index 5c85ba9d5..7037aba93 100644 --- a/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/HangingSignEntity.java @@ -19,193 +19,162 @@ public class HangingSignEntity extends Entity { private static final Quad[] quadsAttached = new Quad[]{ - // top new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector4(2 / 64., 16 / 64., 1 - 12 / 32., 1 - 14 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector4(1 / 16.0, 8 / 16.0, 8 / 16.0, 9 / 16.0) ), - // bottom new Quad( - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(16 / 64., 30 / 64., 1 - 12 / 32., 1 - 14 / 32.) + new Vector3(1 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(1 / 16.0, 8 / 16.0, 2 / 16.0, 3 / 16.0) ), - // left new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(0 / 64., 2 / 64.0, 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(1 / 16.0, 0 / 16.0, 8 / 16.0, 3 / 16.0) ), - // right new Quad( - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(16 / 64., 18 / 64.0, 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(15 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector4(9 / 16.0, 8 / 16.0, 8 / 16.0, 3 / 16.0) ), - // front new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(16 / 64., 2 / 64., 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector4(16 / 16.0, 9 / 16.0, 8 / 16.0, 3 / 16.0) ), - // back new Quad( - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(32 / 64., 18 / 64., 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(8 / 16.0, 1 / 16.0, 8 / 16.0, 3 / 16.0) ), - // chains front new Quad( - new Vector3(-6 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(6 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-6 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(13 / 64., 27 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(2 / 16.0, 16 / 16.0, 8 / 16.0), + new Vector3(14 / 16.0, 16 / 16.0, 8 / 16.0), + new Vector3(2 / 16.0, 10 / 16.0, 8 / 16.0), + new Vector4(10 / 16.0, 16 / 16.0, 16 / 16.0, 13 / 16.0) ), - // chains back new Quad( - new Vector3(6 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-6 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(6 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(13 / 64., 27 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(14 / 16.0, 16 / 16.0, 8 / 16.0), + new Vector3(2 / 16.0, 16 / 16.0, 8 / 16.0), + new Vector3(14 / 16.0, 10 / 16.0, 8 / 16.0), + new Vector4(16 / 16.0, 10 / 16.0, 16 / 16.0, 13 / 16.0) ) }; private static final Quad[] quadsNotAttached = Model.join( new Quad[]{ - // top new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector4(2 / 64., 16 / 64., 1 - 12 / 32., 1 - 14 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector4(1 / 16.0, 8 / 16.0, 8 / 16.0, 9 / 16.0) ), - // bottom new Quad( - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(16 / 64., 30 / 64., 1 - 12 / 32., 1 - 14 / 32.) + new Vector3(1 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(1 / 16.0, 8 / 16.0, 2 / 16.0, 3 / 16.0) ), - // left new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(0 / 64., 2 / 64.0, 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(1 / 16.0, 0 / 16.0, 8 / 16.0, 3 / 16.0) ), - // right new Quad( - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(16 / 64., 18 / 64.0, 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(15 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector4(9 / 16.0, 8 / 16.0, 8 / 16.0, 3 / 16.0) ), - // front new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(16 / 64., 2 / 64., 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector4(16 / 16.0, 9 / 16.0, 8 / 16.0, 3 / 16.0) ), - // back new Quad( - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(32 / 64., 18 / 64., 1 - 14 / 32., 1 - 24 / 32.) - ), + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(8 / 16.0, 1 / 16.0, 8 / 16.0, 3 / 16.0) + ) }, - // chains - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(2.96447 / 16.0, 16 / 16.0, 4.46447 / 16.0), + new Vector3(5.96447 / 16.0, 16 / 16.0, 4.46447 / 16.0), + new Vector3(2.96447 / 16.0, 10 / 16.0, 4.46447 / 16.0), + new Vector4(11 / 16.0, 12.5 / 16.0, 12.5 / 16.0, 9.5 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(5.96447 / 16.0, 16 / 16.0, 4.46447 / 16.0), + new Vector3(2.96447 / 16.0, 16 / 16.0, 4.46447 / 16.0), + new Vector3(5.96447 / 16.0, 10 / 16.0, 4.46447 / 16.0), + new Vector4(12.5 / 16.0, 11 / 16.0, 12.5 / 16.0, 9.5 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(-45)) - .translate(-0.5, -0.5, -0.5) - .translate(-5 / 16.0, 0 / 16.0, 0 / 16.0) + Math.toRadians(45) ), - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(2.96447 / 16.0, 15 / 16.0, 11.53553 / 16.0), + new Vector3(5.96447 / 16.0, 15 / 16.0, 11.53553 / 16.0), + new Vector3(2.96447 / 16.0, 11 / 16.0, 11.53553 / 16.0), + new Vector4(14 / 16.0, 15.5 / 16.0, 12 / 16.0, 10 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(5.96447 / 16.0, 15 / 16.0, 11.53553 / 16.0), + new Vector3(2.96447 / 16.0, 15 / 16.0, 11.53553 / 16.0), + new Vector3(5.96447 / 16.0, 11 / 16.0, 11.53553 / 16.0), + new Vector4(15.5 / 16.0, 14 / 16.0, 12 / 16.0, 10 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(45)) - .translate(-0.5, -0.5, -0.5) - .translate(-5 / 16.0, 0 / 16.0, 0 / 16.0) + Math.toRadians(-45) ), - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(10.03553 / 16.0, 16 / 16.0, 11.53553 / 16.0), + new Vector3(13.03553 / 16.0, 16 / 16.0, 11.53553 / 16.0), + new Vector3(10.03553 / 16.0, 10 / 16.0, 11.53553 / 16.0), + new Vector4(11 / 16.0, 12.5 / 16.0, 12.5 / 16.0, 9.5 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(13.03553 / 16.0, 16 / 16.0, 11.53553 / 16.0), + new Vector3(10.03553 / 16.0, 16 / 16.0, 11.53553 / 16.0), + new Vector3(13.03553 / 16.0, 10 / 16.0, 11.53553 / 16.0), + new Vector4(12.5 / 16.0, 11 / 16.0, 12.5 / 16.0, 9.5 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(-45)) - .translate(-0.5, -0.5, -0.5) - .translate(5 / 16.0, 0 / 16.0, 0 / 16.0) + Math.toRadians(45) ), - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(10.03553 / 16.0, 15 / 16.0, 4.46447 / 16.0), + new Vector3(13.03553 / 16.0, 15 / 16.0, 4.46447 / 16.0), + new Vector3(10.03553 / 16.0, 11 / 16.0, 4.46447 / 16.0), + new Vector4(14 / 16.0, 15.5 / 16.0, 12 / 16.0, 10 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 16 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(13.03553 / 16.0, 15 / 16.0, 4.46447 / 16.0), + new Vector3(10.03553 / 16.0, 15 / 16.0, 4.46447 / 16.0), + new Vector3(13.03553 / 16.0, 11 / 16.0, 4.46447 / 16.0), + new Vector4(15.5 / 16.0, 14 / 16.0, 12 / 16.0, 10 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(45)) - .translate(-0.5, -0.5, -0.5) - .translate(5 / 16.0, 0 / 16.0, 0 / 16.0) + Math.toRadians(-45) ) ); @@ -216,32 +185,22 @@ public class HangingSignEntity extends Entity { private static Quad[] backFaceWithText = new Quad[16]; static { - rotatedQuadsAttached[0] = Model.translate(quadsAttached, 0.5, 0, 0.5); - rotatedQuadsNotAttached[0] = Model.translate(quadsNotAttached, 0.5, 0, 0.5); + rotatedQuadsAttached[0] = quadsAttached; + rotatedQuadsNotAttached[0] = quadsNotAttached; for (int i = 1; i < 16; ++i) { rotatedQuadsAttached[i] = Model.rotateY(rotatedQuadsAttached[0], Math.PI - i * Math.PI / 8); rotatedQuadsNotAttached[i] = Model.rotateY(rotatedQuadsNotAttached[0], Math.PI - i * Math.PI / 8); } - frontFaceWithText[0] = new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(1, 0, 1, 0) - ); - frontFaceWithText[0] = frontFaceWithText[0].transform(Transform.NONE.translate(0.5, 0, 0.5)); + frontFaceWithText[0] = new Quad(quadsAttached[4], Transform.NONE); + frontFaceWithText[0].uv.set(0, 1, 0, 1); for (int i = 1; i < 16; ++i) { frontFaceWithText[i] = frontFaceWithText[0].transform(Transform.NONE.rotateY(Math.PI - i * Math.PI / 8)); } - backFaceWithText[0] = new Quad( - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(1, 0, 1, 0) - ); - backFaceWithText[0] = backFaceWithText[0].transform(Transform.NONE.translate(0.5, 0, 0.5)); + backFaceWithText[0] = new Quad(quadsAttached[5], Transform.NONE); + backFaceWithText[0].uv.set(0, 1, 0, 1); for (int i = 1; i < 16; ++i) { backFaceWithText[i] = backFaceWithText[0].transform(Transform.NONE.rotateY(Math.PI - i * Math.PI / 8)); } @@ -275,8 +234,8 @@ public HangingSignEntity(Vector3 position, JsonArray[] frontText, SignEntity.Col this.backGlowing = backGlowing; this.angle = rotation; this.attached = attached; - this.frontTexture = frontText != null ? new SignTexture(frontText, frontDye, frontGlowing, signTexture, 14, 10, 2 / 64., 1 - 24 / 32., 16 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; - this.backTexture = backText != null ? new SignTexture(backText, backDye, backGlowing, signTexture, 14, 10, 18 / 64., 1 - 24 / 32., 32 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; + this.frontTexture = frontText != null ? new SignTexture(frontText, frontDye, frontGlowing, signTexture, 14, 10, 2 / 32., 16 / 32., 16 / 32., 26 / 32., 4.5, 3, 9) : null; + this.backTexture = backText != null ? new SignTexture(backText, backDye, backGlowing, signTexture, 14, 10, 18 / 32., 16 / 32., 32 / 32., 26 / 32., 4.5, 3, 9) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java index 4ccbe059f..03d5540df 100644 --- a/chunky/src/java/se/llbit/chunky/entity/SignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/SignEntity.java @@ -235,58 +235,77 @@ public Color getGlowingOutlineColor() { } // Facing south. - protected static Quad[] sides = { - // Front face. - new Quad(new Vector3(0, 9 / 16., 9 / 16.), new Vector3(1, 9 / 16., 9 / 16.), - new Vector3(0, 17 / 16., 9 / 16.), new Vector4(2 / 64., 26 / 64., 18 / 32., 30 / 32.)), - - // Back face. - new Quad(new Vector3(1, 9 / 16., 7 / 16.), new Vector3(0, 9 / 16., 7 / 16.), - new Vector3(1, 17 / 16., 7 / 16.), new Vector4(28 / 64., 52 / 64., 18 / 32., 30 / 32.)), - - // Left face. - new Quad(new Vector3(0, 9 / 16., 7 / 16.), new Vector3(0, 9 / 16., 9 / 16.), - new Vector3(0, 17 / 16., 7 / 16.), new Vector4(0, 2 / 64., 18 / 32., 30 / 32.)), - - // Right face. - new Quad(new Vector3(1, 9 / 16., 9 / 16.), new Vector3(1, 9 / 16., 7 / 16.), - new Vector3(1, 17 / 16., 9 / 16.), new Vector4(26 / 64., 28 / 64., 18 / 32., 30 / 32.)), - - // Top face. - new Quad(new Vector3(1, 17 / 16., 7 / 16.), new Vector3(0, 17 / 16., 7 / 16.), - new Vector3(1, 17 / 16., 9 / 16.), new Vector4(2 / 64., 26 / 64., 1, 30 / 32.)), - - // Bottom face. - new Quad(new Vector3(0, 9 / 16., 7 / 16.), new Vector3(1, 9 / 16., 7 / 16.), - new Vector3(0, 9 / 16., 9 / 16.), new Vector4(26 / 64., 50 / 64., 1, 30 / 32.)), - - // Post front. - new Quad(new Vector3(7 / 16., 0, 9 / 16.), new Vector3(9 / 16., 0, 9 / 16.), - new Vector3(7 / 16., 9 / 16., 9 / 16.), - new Vector4(2 / 64., 4 / 64., 2 / 32., 16 / 32.)), - - // Post back. - new Quad(new Vector3(9 / 16., 0, 7 / 16.), new Vector3(7 / 16., 0, 7 / 16.), - new Vector3(9 / 16., 9 / 16., 7 / 16.), - new Vector4(4 / 64., 6 / 64., 2 / 32., 16 / 32.)), - - // Post left. - new Quad(new Vector3(7 / 16., 0, 7 / 16.), new Vector3(7 / 16., 0, 9 / 16.), - new Vector3(7 / 16., 9 / 16., 7 / 16.), new Vector4(0, 2 / 64., 2 / 32., 16 / 32.)), - - // Post right. - new Quad(new Vector3(9 / 16., 0, 9 / 16.), new Vector3(9 / 16., 0, 7 / 16.), - new Vector3(9 / 16., 9 / 16., 9 / 16.), - new Vector4(6 / 64., 8 / 64., 2 / 32., 16 / 32.)), - - // Post bottom. - new Quad(new Vector3(7 / 16., 0, 7 / 16.), new Vector3(9 / 16., 0, 7 / 16.), - new Vector3(7 / 16., 0, 9 / 16.), new Vector4(4 / 64., 6 / 64., 16 / 32., 18 / 32.)), - + protected static Quad[] sides = new Quad[]{ + new Quad( // sign back face + new Vector3(16 / 16.0, 17.33333 / 16.0, 8.66667 / 16.0), + new Vector3(0 / 16.0, 17.33333 / 16.0, 8.66667 / 16.0), + new Vector3(16 / 16.0, 9.33333 / 16.0, 8.66667 / 16.0), + new Vector4(12 / 16.0, 0 / 16.0, 15 / 16.0, 9 / 16.0) + ), + new Quad( // sign front face + new Vector3(0 / 16.0, 17.33333 / 16.0, 7.33333 / 16.0), + new Vector3(16 / 16.0, 17.33333 / 16.0, 7.33333 / 16.0), + new Vector3(0 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector4(12 / 16.0, 0 / 16.0, 8 / 16.0, 2 / 16.0) + ), + new Quad( + new Vector3(7.33333 / 16.0, 0 / 16.0, 7.33333 / 16.0), + new Vector3(8.66667 / 16.0, 0 / 16.0, 7.33333 / 16.0), + new Vector3(7.33333 / 16.0, 0 / 16.0, 8.66667 / 16.0), + new Vector4(14 / 16.0, 15 / 16.0, 0 / 16.0, 1 / 16.0) + ), + new Quad( + new Vector3(7.33333 / 16.0, 9.33333 / 16.0, 8.66667 / 16.0), + new Vector3(7.33333 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector3(7.33333 / 16.0, 0 / 16.0, 8.66667 / 16.0), + new Vector4(16 / 16.0, 15 / 16.0, 8 / 16.0, 1 / 16.0) + ), + new Quad( + new Vector3(8.66667 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector3(8.66667 / 16.0, 9.33333 / 16.0, 8.66667 / 16.0), + new Vector3(8.66667 / 16.0, 0 / 16.0, 7.33333 / 16.0), + new Vector4(16 / 16.0, 15 / 16.0, 16 / 16.0, 9 / 16.0) + ), + new Quad( + new Vector3(7.33333 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector3(8.66667 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector3(7.33333 / 16.0, 0 / 16.0, 7.33333 / 16.0), + new Vector4(15 / 16.0, 14 / 16.0, 8 / 16.0, 1 / 16.0) + ), + new Quad( + new Vector3(8.66667 / 16.0, 9.33333 / 16.0, 8.66667 / 16.0), + new Vector3(7.33333 / 16.0, 9.33333 / 16.0, 8.66667 / 16.0), + new Vector3(8.66667 / 16.0, 0 / 16.0, 8.66667 / 16.0), + new Vector4(15 / 16.0, 14 / 16.0, 16 / 16.0, 9 / 16.0) + ), + new Quad( + new Vector3(0 / 16.0, 17.33333 / 16.0, 8.66667 / 16.0), + new Vector3(16 / 16.0, 17.33333 / 16.0, 8.66667 / 16.0), + new Vector3(0 / 16.0, 17.33333 / 16.0, 7.33333 / 16.0), + new Vector4(0 / 16.0, 12 / 16.0, 15 / 16.0, 16 / 16.0) + ), + new Quad( + new Vector3(0 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector3(16 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector3(0 / 16.0, 9.33333 / 16.0, 8.66667 / 16.0), + new Vector4(0 / 16.0, 12 / 16.0, 1 / 16.0, 2 / 16.0) + ), + new Quad( + new Vector3(0 / 16.0, 17.33333 / 16.0, 8.66667 / 16.0), + new Vector3(0 / 16.0, 17.33333 / 16.0, 7.33333 / 16.0), + new Vector3(0 / 16.0, 9.33333 / 16.0, 8.66667 / 16.0), + new Vector4(13 / 16.0, 12 / 16.0, 8 / 16.0, 2 / 16.0) + ), + new Quad( + new Vector3(16 / 16.0, 17.33333 / 16.0, 7.33333 / 16.0), + new Vector3(16 / 16.0, 17.33333 / 16.0, 8.66667 / 16.0), + new Vector3(16 / 16.0, 9.33333 / 16.0, 7.33333 / 16.0), + new Vector4(13 / 16.0, 12 / 16.0, 15 / 16.0, 9 / 16.0) + ) }; - private static Quad[] frontFaceWithText = new Quad[16]; - private static Quad[] backFaceWithText = new Quad[16]; + private static final Quad[] frontFaceWithText = new Quad[16]; + private static final Quad[] backFaceWithText = new Quad[16]; private static final Quad[][] rot = new Quad[16][]; @@ -297,14 +316,14 @@ public Color getGlowingOutlineColor() { rot[i] = Model.rotateY(sides, -i * Math.PI / 8); } - frontFaceWithText[0] = new Quad(new Vector3(0, 9 / 16., 9 / 16.), new Vector3(1, 9 / 16., 9 / 16.), - new Vector3(0, 17 / 16., 9 / 16.), new Vector4(0, 1, 0, 1)); + frontFaceWithText[0] = new Quad(rot[0][0], Transform.NONE); + frontFaceWithText[0].uv.set(0, 1, 0, 1); for (int i = 1; i < 16; ++i) { frontFaceWithText[i] = frontFaceWithText[0].transform(Transform.NONE.rotateY(-i * Math.PI / 8)); } - backFaceWithText[0] = new Quad(new Vector3(1, 9 / 16., 7 / 16.), new Vector3(0, 9 / 16., 7 / 16.), - new Vector3(1, 17 / 16., 7 / 16.), new Vector4(0, 1, 0, 1)); + backFaceWithText[0] = new Quad(rot[0][1], Transform.NONE); + backFaceWithText[0].uv.set(0, 1, 0, 1); for (int i = 1; i < 16; ++i) { backFaceWithText[i] = backFaceWithText[0].transform(Transform.NONE.rotateY(-i * Math.PI / 8)); } @@ -336,8 +355,8 @@ public SignEntity(Vector3 position, JsonArray[] frontText, Color frontDye, boole this.frontGlowing = frontGlowing; this.backGlowing = backGlowing; this.angle = direction; - this.frontTexture = frontText != null ? new SignTexture(frontText, frontDye, frontGlowing, signTexture, 24, 12, 2 / 64., 18 / 32., 26 / 64., 30 / 32., 4, 1, 10) : null; - this.backTexture = backText != null ? new SignTexture(backText, backDye, backGlowing, signTexture, 24, 12, 28 / 64., 18 / 32., 52 / 64., 30 / 32., 4, 1, 10) : null; + this.frontTexture = frontText != null ? new SignTexture(frontText, frontDye, frontGlowing, signTexture, 24, 12, 0 / 32., 2 / 32., 24 / 32., 14 / 32., 4, 1, 10) : null; + this.backTexture = backText != null ? new SignTexture(backText, backDye, backGlowing, signTexture, 24, 12, 0 / 32., 16 / 32., 24 / 32., 28 / 32., 4, 1, 10) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java index ab2b75f2a..dee93a532 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallHangingSignEntity.java @@ -21,177 +21,152 @@ public class WallHangingSignEntity extends Entity { private static final Quad[] quads = Model.join( new Quad[]{ - // sign top new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector4(2 / 64., 16 / 64., 1 - 12 / 32., 1 - 14 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector4(1 / 16.0, 8 / 16.0, 8 / 16.0, 9 / 16.0) ), - // sign bottom new Quad( - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(16 / 64., 30 / 64., 1 - 12 / 32., 1 - 14 / 32.) + new Vector3(1 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(1 / 16.0, 8 / 16.0, 2 / 16.0, 3 / 16.0) ), - // sign left new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(0 / 64., 2 / 64.0, 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(1 / 16.0, 0 / 16.0, 8 / 16.0, 3 / 16.0) ), - // sign right new Quad( - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(16 / 64., 18 / 64.0, 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(15 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector4(9 / 16.0, 8 / 16.0, 8 / 16.0, 3 / 16.0) ), - // sign front new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(16 / 64., 2 / 64., 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(1 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(15 / 16.0, 10 / 16.0, 7 / 16.0), + new Vector3(1 / 16.0, 0 / 16.0, 7 / 16.0), + new Vector4(16 / 16.0, 9 / 16.0, 8 / 16.0, 3 / 16.0) ), - // sign back new Quad( - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(32 / 64., 18 / 64., 1 - 14 / 32., 1 - 24 / 32.) + new Vector3(15 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(1 / 16.0, 10 / 16.0, 9 / 16.0), + new Vector3(15 / 16.0, 0 / 16.0, 9 / 16.0), + new Vector4(8 / 16.0, 1 / 16.0, 8 / 16.0, 3 / 16.0) ) }, new Quad[]{ - // bar top new Quad( - new Vector3(-8 / 16.0, 16 / 16.0, 2 / 16.0), - new Vector3(8 / 16.0, 16 / 16.0, 2 / 16.0), - new Vector3(-8 / 16.0, 16 / 16.0, -2 / 16.0), - new Vector4(4 / 64., 20 / 64., 1 - 0 / 32., 1 - 4 / 32.) + new Vector3(0 / 16.0, 16 / 16.0, 10 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 10 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 6 / 16.0), + new Vector4(0 / 16.0, 8 / 16.0, 14 / 16.0, 16 / 16.0) ), - // bar bottom new Quad( - new Vector3(-8 / 16.0, 14 / 16.0, -2 / 16.0), - new Vector3(8 / 16.0, 14 / 16.0, -2 / 16.0), - new Vector3(-8 / 16.0, 14 / 16.0, 2 / 16.0), - new Vector4(20 / 64., 36 / 64., 1 - 0 / 32., 1 - 4 / 32.) + new Vector3(0 / 16.0, 14 / 16.0, 6 / 16.0), + new Vector3(16 / 16.0, 14 / 16.0, 6 / 16.0), + new Vector3(0 / 16.0, 14 / 16.0, 10 / 16.0), + new Vector4(8 / 16.0, 0 / 16.0, 9.5 / 16.0, 11.5 / 16.0) ), - // bar left new Quad( - new Vector3(-8 / 16.0, 16 / 16.0, 2 / 16.0), - new Vector3(-8 / 16.0, 16 / 16.0, -2 / 16.0), - new Vector3(-8 / 16.0, 14 / 16.0, 2 / 16.0), - new Vector4(0 / 64., 4 / 64., 1 - 4 / 32., 1 - 6 / 32.) + new Vector3(0 / 16.0, 16 / 16.0, 10 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 6 / 16.0), + new Vector3(0 / 16.0, 14 / 16.0, 10 / 16.0), + new Vector4(10 / 16.0, 8 / 16.0, 12.5 / 16.0, 11.5 / 16.0) ), - // bar right new Quad( - new Vector3(8 / 16.0, 16 / 16.0, -2 / 16.0), - new Vector3(8 / 16.0, 16 / 16.0, 2 / 16.0), - new Vector3(8 / 16.0, 14 / 16.0, -2 / 16.0), - new Vector4(20 / 64., 24 / 64., 1 - 4 / 32., 1 - 6 / 32.) + new Vector3(16 / 16.0, 16 / 16.0, 6 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 10 / 16.0), + new Vector3(16 / 16.0, 14 / 16.0, 6 / 16.0), + new Vector4(10 / 16.0, 8 / 16.0, 14 / 16.0, 13 / 16.0) ), - // bar front new Quad( - new Vector3(-8 / 16.0, 16 / 16.0, -2 / 16.0), - new Vector3(8 / 16.0, 16 / 16.0, -2 / 16.0), - new Vector3(-8 / 16.0, 14 / 16.0, -2 / 16.0), - new Vector4(4 / 64., 20 / 64., 1 - 4 / 32., 1 - 6 / 32.) + new Vector3(0 / 16.0, 16 / 16.0, 6 / 16.0), + new Vector3(16 / 16.0, 16 / 16.0, 6 / 16.0), + new Vector3(0 / 16.0, 14 / 16.0, 6 / 16.0), + new Vector4(8 / 16.0, 0 / 16.0, 12.5 / 16.0, 11.5 / 16.0) ), - // bar back new Quad( - new Vector3(8 / 16.0, 16 / 16.0, 2 / 16.0), - new Vector3(-8 / 16.0, 16 / 16.0, 2 / 16.0), - new Vector3(8 / 16.0, 14 / 16.0, 2 / 16.0), - new Vector4(24 / 64., 40 / 64., 1 - 4 / 32., 1 - 6 / 32.) + new Vector3(16 / 16.0, 16 / 16.0, 10 / 16.0), + new Vector3(0 / 16.0, 16 / 16.0, 10 / 16.0), + new Vector3(16 / 16.0, 14 / 16.0, 10 / 16.0), + new Vector4(8 / 16.0, 0 / 16.0, 14 / 16.0, 13 / 16.0) ) }, - // chains - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(1.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(4.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(1.5 / 16.0, 10 / 16.0, 8 / 16.0), + new Vector4(11 / 16.0, 12.5 / 16.0, 10.5 / 16.0, 9.5 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(4.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(1.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(4.5 / 16.0, 10 / 16.0, 8 / 16.0), + new Vector4(12.5 / 16.0, 11 / 16.0, 10.5 / 16.0, 9.5 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(-45)) - .translate(-0.5, -0.5, -0.5) - .translate(-5 / 16.0, 6 / 16.0, 0 / 16.0) + Math.toRadians(45), + new Vector3(3 / 16.0, 0, 8 / 16.0) ), - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(1.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(4.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(1.5 / 16.0, 11 / 16.0, 8 / 16.0), + new Vector4(14 / 16.0, 15.5 / 16.0, 11.5 / 16.0, 10 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(4.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(1.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(4.5 / 16.0, 11 / 16.0, 8 / 16.0), + new Vector4(15.5 / 16.0, 14 / 16.0, 11.5 / 16.0, 10 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(45)) - .translate(-0.5, -0.5, -0.5) - .translate(-5 / 16.0, 6 / 16.0, 0 / 16.0) + Math.toRadians(-45), + new Vector3(3 / 16.0, 0, 8 / 16.0) ), - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(11.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(14.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(11.5 / 16.0, 10 / 16.0, 8 / 16.0), + new Vector4(11 / 16.0, 12.5 / 16.0, 10.5 / 16.0, 9.5 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(6 / 64., 9 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(14.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(11.5 / 16.0, 12 / 16.0, 8 / 16.0), + new Vector3(14.5 / 16.0, 10 / 16.0, 8 / 16.0), + new Vector4(12.5 / 16.0, 11 / 16.0, 10.5 / 16.0, 9.5 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(-45)) - .translate(-0.5, -0.5, -0.5) - .translate(5 / 16.0, 6 / 16.0, 0 / 16.0) + Math.toRadians(45), + new Vector3(13 / 16.0, 0, 8 / 16.0) ), - Model.transform( + Model.rotateY( new Quad[]{ new Quad( - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(11.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(14.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(11.5 / 16.0, 11 / 16.0, 8 / 16.0), + new Vector4(14 / 16.0, 15.5 / 16.0, 11.5 / 16.0, 10 / 16.0) ), new Quad( - new Vector3(1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(-1.5 / 16.0, 10 / 16.0, 0 / 16.0), - new Vector3(1.5 / 16.0, 4 / 16.0, 0 / 16.0), - new Vector4(0 / 64., 3 / 64., 1 - 6 / 32., 1 - 12 / 32.) + new Vector3(14.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(11.5 / 16.0, 14 / 16.0, 8 / 16.0), + new Vector3(14.5 / 16.0, 11 / 16.0, 8 / 16.0), + new Vector4(15.5 / 16.0, 14 / 16.0, 11.5 / 16.0, 10 / 16.0) ) }, - Transform.NONE - .translate(0.5, 0.5, 0.5) - .rotateY(Math.toRadians(45)) - .translate(-0.5, -0.5, -0.5) - .translate(5 / 16.0, 6 / 16.0, 0 / 16.0) + Math.toRadians(-45), + new Vector3(13 / 16.0, 0, 8 / 16.0) ) ); private static Quad[][] rotatedQuads = new Quad[4][]; @@ -200,29 +175,19 @@ public class WallHangingSignEntity extends Entity { private static Quad[] backFaceWithText = new Quad[4]; static { - rotatedQuads[0] = Model.translate(quads, 0.5, 0, 0.5); + rotatedQuads[0] = quads; rotatedQuads[1] = Model.rotateY(rotatedQuads[0]); rotatedQuads[2] = Model.rotateY(rotatedQuads[1]); rotatedQuads[3] = Model.rotateY(rotatedQuads[2]); - frontFaceWithText[0] = new Quad( - new Vector3(-7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(7 / 16.0, 10 / 16.0, -1 / 16.0), - new Vector3(-7 / 16.0, 0 / 16.0, -1 / 16.0), - new Vector4(1, 0, 1, 0) - ); - frontFaceWithText[0] = frontFaceWithText[0].transform(Transform.NONE.translate(0.5, 0, 0.5)); + frontFaceWithText[0] = new Quad(quads[4], Transform.NONE); + frontFaceWithText[0].uv.set(0, 1, 0, 1); frontFaceWithText[1] = frontFaceWithText[0].transform(Transform.NONE.rotateY()); frontFaceWithText[2] = frontFaceWithText[1].transform(Transform.NONE.rotateY()); frontFaceWithText[3] = frontFaceWithText[2].transform(Transform.NONE.rotateY()); - backFaceWithText[0] = new Quad( - new Vector3(7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(-7 / 16.0, 10 / 16.0, 1 / 16.0), - new Vector3(7 / 16.0, 0 / 16.0, 1 / 16.0), - new Vector4(1, 0, 1, 0) - ); - backFaceWithText[0] = backFaceWithText[0].transform(Transform.NONE.translate(0.5, 0, 0.5)); + backFaceWithText[0] = new Quad(quads[5], Transform.NONE); + backFaceWithText[0].uv.set(0, 1, 0, 1); backFaceWithText[1] = backFaceWithText[0].transform(Transform.NONE.rotateY()); backFaceWithText[2] = backFaceWithText[1].transform(Transform.NONE.rotateY()); backFaceWithText[3] = backFaceWithText[2].transform(Transform.NONE.rotateY()); @@ -254,8 +219,8 @@ public WallHangingSignEntity(Vector3 position, JsonArray[] frontText, SignEntity this.frontGlowing = frontGlowing; this.backGlowing = backGlowing; this.orientation = direction; - this.frontTexture = frontText != null ? new SignTexture(frontText, frontDye, frontGlowing, signTexture, 14, 10, 2 / 64., 1 - 24 / 32., 16 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; - this.backTexture = backText != null ? new SignTexture(backText, backDye, backGlowing, signTexture, 14, 10, 18 / 64., 1 - 24 / 32., 32 / 64., 1 - 14 / 32., 4.5, 3, 9) : null; + this.frontTexture = frontText != null ? new SignTexture(frontText, frontDye, frontGlowing, signTexture, 14, 10, 2 / 32., 16 / 32., 16 / 32., 26 / 32., 4.5, 3, 9) : null; + this.backTexture = backText != null ? new SignTexture(backText, backDye, backGlowing, signTexture, 14, 10, 18 / 32., 16 / 32., 32 / 32., 26 / 32., 4.5, 3, 9) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java index 336b94965..c09691ece 100644 --- a/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java +++ b/chunky/src/java/se/llbit/chunky/entity/WallSignEntity.java @@ -40,37 +40,49 @@ public class WallSignEntity extends Entity { private static final double offset = 0.02; private static Quad[][] faces = {{}, {}, - // Facing north + {}, + + // Facing south { // North (front) face. - new Quad(new Vector3(1, 4.5 / 16, .875 + offset), new Vector3(0, 4.5 / 16, .875 + offset), - new Vector3(1, 12.5 / 16, .875 + offset), new Vector4(2 / 64., 26 / 64., 18 / 32., 30 / 32.)), - - // South (back) face. - new Quad(new Vector3(0, 4.5 / 16, 1 - offset), new Vector3(1, 4.5 / 16, 1 - offset), - new Vector3(0, 12.5 / 16, 1 - offset), - new Vector4(28 / 64., 52 / 64., 18 / 32., 30 / 32.)), - - // West (left) face. - new Quad(new Vector3(0, 4.5 / 16, .875 + offset), new Vector3(0, 4.5 / 16, 1 - offset), - new Vector3(0, 12.5 / 16, .875 + offset), - new Vector4(26 / 64., 28 / 64., 18 / 32., 30 / 32.)), - - // East (right) face. - new Quad(new Vector3(1, 4.5 / 16, 1 - offset), new Vector3(1, 4.5 / 16, .875 + offset), - new Vector3(1, 12.5 / 16, 1 - offset), new Vector4(0, 2 / 64., 18 / 32., 30 / 32.)), - - // Top face. - new Quad(new Vector3(1, 12.5 / 16, .875 + offset), new Vector3(0, 12.5 / 16, .875 + offset), - new Vector3(1, 12.5 / 16, 1 - offset), new Vector4(2 / 64., 26 / 64., 30 / 32., 1)), - - // Bottom face - new Quad(new Vector3(0, 4.5 / 16, .875 + offset), new Vector3(1, 4.5 / 16, .875 + offset), - new Vector3(0, 4.5 / 16, 1 - offset), new Vector4(50 / 64., 26 / 64., 30 / 32., 1)),}, - - // Facing south. - {}, + new Quad( + new Vector3(16 / 16.0, 12.33333 / 16.0, 1.66667 / 16.0), + new Vector3(0 / 16.0, 12.33333 / 16.0, 1.66667 / 16.0), + new Vector3(16 / 16.0, 4.33333 / 16.0, 1.66667 / 16.0), + new Vector4(12 / 16.0, 0 / 16.0, 15 / 16.0, 9 / 16.0) + ), + new Quad( + new Vector3(0 / 16.0, 12.33333 / 16.0, 1.66667 / 16.0), + new Vector3(16 / 16.0, 12.33333 / 16.0, 1.66667 / 16.0), + new Vector3(0 / 16.0, 12.33333 / 16.0, 0.33333 / 16.0), + new Vector4(0 / 16.0, 12 / 16.0, 15 / 16.0, 16 / 16.0) + ), + new Quad( + new Vector3(0 / 16.0, 4.33333 / 16.0, 0.33333 / 16.0), + new Vector3(16 / 16.0, 4.33333 / 16.0, 0.33333 / 16.0), + new Vector3(0 / 16.0, 4.33333 / 16.0, 1.66667 / 16.0), + new Vector4(0 / 16.0, 12 / 16.0, 1 / 16.0, 2 / 16.0) + ), + new Quad( + new Vector3(0 / 16.0, 12.33333 / 16.0, 1.66667 / 16.0), + new Vector3(0 / 16.0, 12.33333 / 16.0, 0.33333 / 16.0), + new Vector3(0 / 16.0, 4.33333 / 16.0, 1.66667 / 16.0), + new Vector4(13 / 16.0, 12 / 16.0, 8 / 16.0, 2 / 16.0) + ), + new Quad( + new Vector3(16 / 16.0, 12.33333 / 16.0, 0.33333 / 16.0), + new Vector3(16 / 16.0, 12.33333 / 16.0, 1.66667 / 16.0), + new Vector3(16 / 16.0, 4.33333 / 16.0, 0.33333 / 16.0), + new Vector4(13 / 16.0, 12 / 16.0, 15 / 16.0, 9 / 16.0) + ), + new Quad( + new Vector3(0 / 16.0, 12.33333 / 16.0, 0.33333 / 16.0), + new Vector3(16 / 16.0, 12.33333 / 16.0, 0.33333 / 16.0), + new Vector3(0 / 16.0, 4.33333 / 16.0, 0.33333 / 16.0), + new Vector4(12 / 16.0, 0 / 16.0, 8 / 16.0, 2 / 16.0) + ) + }, // Facing west. {}, @@ -81,15 +93,15 @@ public class WallSignEntity extends Entity { private static Quad[] frontFaceWithText = new Quad[6]; static { - faces[5] = Model.rotateY(faces[2]); - faces[3] = Model.rotateY(faces[5]); faces[4] = Model.rotateY(faces[3]); + faces[2] = Model.rotateY(faces[4]); + faces[5] = Model.rotateY(faces[2]); - frontFaceWithText[2] = new Quad(new Vector3(1, 4.5 / 16, .875 + offset), new Vector3(0, 4.5 / 16, .875 + offset), - new Vector3(1, 12.5 / 16, .875 + offset), new Vector4(0, 1, 0, 1)); - frontFaceWithText[5] = frontFaceWithText[2].transform(Transform.NONE.rotateY()); - frontFaceWithText[3] = frontFaceWithText[5].transform(Transform.NONE.rotateY()); + frontFaceWithText[3] = new Quad(faces[3][0], Transform.NONE); + frontFaceWithText[3].uv.set(0, 1, 0, 1); frontFaceWithText[4] = frontFaceWithText[3].transform(Transform.NONE.rotateY()); + frontFaceWithText[2] = frontFaceWithText[4].transform(Transform.NONE.rotateY()); + frontFaceWithText[5] = frontFaceWithText[2].transform(Transform.NONE.rotateY()); } private final JsonArray[] text; @@ -111,7 +123,7 @@ public WallSignEntity(Vector3 position, JsonArray[] text, SignEntity.Color dye, this.text = text; this.dye = dye; this.glowing = isGlowing; - this.frontTexture = text != null ? new SignTexture(text, dye, isGlowing, signTexture, 24, 12, 2 / 64., 18 / 32., 26 / 64., 30 / 32., 4, 1, 10) : null; + this.frontTexture = text != null ? new SignTexture(text, dye, isGlowing, signTexture, 24, 12, 0 / 32., 2 / 32., 24 / 32., 14 / 32., 4, 1, 10) : null; this.texture = signTexture; this.material = material; } diff --git a/chunky/src/java/se/llbit/chunky/resources/SignTexture.java b/chunky/src/java/se/llbit/chunky/resources/SignTexture.java index 7a33e4bb1..57eb3e2d4 100644 --- a/chunky/src/java/se/llbit/chunky/resources/SignTexture.java +++ b/chunky/src/java/se/llbit/chunky/resources/SignTexture.java @@ -151,8 +151,8 @@ public SignTexture(JsonArray[] text, Color dyeColor, boolean isGlowing, Texture @Override public float[] getColor(double u, double v) { if (textColor != null) { - int x = (int) (u * textColor.width - Ray.EPSILON); - int y = (int) ((1 - v) * textColor.height - Ray.EPSILON); + int x = (int) ((1 - u) * textColor.width - Ray.EPSILON); + int y = (int) (v * textColor.height - Ray.EPSILON); if (textMask != null && textMask.getPixel(x, y)) { Color characterColor = Color.get(textColor.getPixel(x, y)); return characterColor.linearColor; @@ -166,6 +166,6 @@ public float[] getColor(double u, double v) { return dyeColor.getGlowingOutlineColor().linearColor; } } - return signTexture.getColor(u * ww + u0, v * hh + v0); + return signTexture.getColor((1 - u) * ww + u0, 1 - (v * hh + v0)); } } diff --git a/chunky/src/java/se/llbit/chunky/resources/Texture.java b/chunky/src/java/se/llbit/chunky/resources/Texture.java index ee5db432f..e70de5e81 100644 --- a/chunky/src/java/se/llbit/chunky/resources/Texture.java +++ b/chunky/src/java/se/llbit/chunky/resources/Texture.java @@ -1088,7 +1088,6 @@ public class Texture { public static final Texture strippedMangroveLog = new Texture(); @TexturePath("assets/minecraft/textures/block/stripped_mangrove_log_top") public static final Texture strippedMangroveLogTop = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/mangrove") public static final Texture mangroveSignPost = new Texture(); @TexturePath("assets/minecraft/textures/block/mangrove_trapdoor") public static final Texture mangroveTrapdoor = new Texture(); @@ -1142,7 +1141,6 @@ public class Texture { public static final Texture strippedBambooBlock = new Texture(); @TexturePath("assets/minecraft/textures/block/stripped_bamboo_block_top") public static final Texture strippedBambooBlockTop = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/bamboo") public static final Texture bambooSignPost = new Texture(); @TexturePath("assets/minecraft/textures/block/bamboo_trapdoor") public static final Texture bambooTrapdoor = new Texture(); @@ -1163,7 +1161,6 @@ public class Texture { public static final Texture strippedCherryLog = new Texture(); @TexturePath("assets/minecraft/textures/block/stripped_cherry_log_top") public static final Texture strippedCherryLogTop = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/cherry") public static final Texture cherrySignPost = new Texture(); @TexturePath("assets/minecraft/textures/block/cherry_trapdoor") public static final Texture cherryTrapdoor = new Texture(); @@ -1314,27 +1311,16 @@ public class Texture { public static final Texture calibratedSculkSensorTop = new Texture(); @TexturePath("assets/minecraft/textures/block/calibrated_sculk_sensor_input_side") public static final Texture calibratedSculkSensorInputSide = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/oak") public static final Texture oakHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/spruce") public static final Texture spruceHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/birch") public static final Texture birchHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/jungle") public static final Texture jungleHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/acacia") public static final Texture acaciaHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/dark_oak") public static final Texture darkOakHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/crimson") public static final Texture crimsonHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/warped") public static final Texture warpedHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/mangrove") public static final Texture mangroveHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/bamboo") public static final Texture bambooHangingSign = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/cherry") public static final Texture cherryHangingSign = new Texture(); @TexturePath("assets/minecraft/textures/entity/piglin/piglin") public static final Texture piglin = new Texture(); @@ -1538,9 +1524,7 @@ public class Texture { public static final Texture strippedPaleOakLogTop = new Texture(); @TexturePath("assets/minecraft/textures/block/pale_oak_sapling") public static final Texture paleOakSapling = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/pale_oak") public static final Texture paleOakSignPost = new Texture(); - @TexturePath("assets/minecraft/textures/entity/signs/hanging/pale_oak") public static final Texture paleOakHangingSign = new Texture(); @TexturePath("assets/minecraft/textures/block/pale_moss_carpet") public static final Texture paleMossCarpet = new Texture(); diff --git a/chunky/src/java/se/llbit/chunky/resources/TexturePackLoader.java b/chunky/src/java/se/llbit/chunky/resources/TexturePackLoader.java index 474a07ef2..0c1dd48cf 100644 --- a/chunky/src/java/se/llbit/chunky/resources/TexturePackLoader.java +++ b/chunky/src/java/se/llbit/chunky/resources/TexturePackLoader.java @@ -19,10 +19,12 @@ import se.llbit.chunky.renderer.scene.PlayerModel; import se.llbit.chunky.renderer.scene.sky.Sun; import se.llbit.chunky.resources.texturepack.*; +import se.llbit.chunky.resources.texturepack.SignTexture; import se.llbit.log.Log; import java.lang.reflect.Field; -import java.util.*; +import java.util.HashMap; +import java.util.Map; /** * Utility methods to load Minecraft texture packs. @@ -3231,20 +3233,31 @@ public class TexturePackLoader { new SimpleTexture("assets/minecraft/textures/block/loom_top", Texture.loomTop)); - ALL_TEXTURES.put("sign_acacia", - new SimpleTexture("assets/minecraft/textures/entity/signs/acacia", Texture.acaciaSignPost)); - ALL_TEXTURES.put("sign_birch", - new SimpleTexture("assets/minecraft/textures/entity/signs/birch", Texture.birchSignPost)); - ALL_TEXTURES.put("sign_dark_oak", - new SimpleTexture("assets/minecraft/textures/entity/signs/dark_oak", Texture.darkOakSignPost)); - ALL_TEXTURES.put("sign_jungle", - new SimpleTexture("assets/minecraft/textures/entity/signs/jungle", Texture.jungleSignPost)); - ALL_TEXTURES.put("sign_oak", new AlternateTextures( - new SimpleTexture("assets/minecraft/textures/entity/signs/oak", Texture.oakSignPost),// MC 1.14 - new SimpleTexture("assets/minecraft/textures/entity/sign", Texture.oakSignPost),// MC 1.6 - new SimpleTexture("item/sign", Texture.oakSignPost))); - ALL_TEXTURES.put("sign_spruce", - new SimpleTexture("assets/minecraft/textures/entity/signs/spruce", Texture.spruceSignPost)); + ALL_TEXTURES.put("sign_acacia", SignTexture.createSignTextureLoader("acacia", Texture.acaciaSignPost)); + ALL_TEXTURES.put("sign_birch", SignTexture.createSignTextureLoader("birch", Texture.birchSignPost)); + ALL_TEXTURES.put("sign_dark_oak", SignTexture.createSignTextureLoader("dark_oak", Texture.darkOakSignPost)); + ALL_TEXTURES.put("sign_jungle", SignTexture.createSignTextureLoader("jungle", Texture.jungleSignPost)); + ALL_TEXTURES.put("sign_oak", SignTexture.createSignTextureLoader("oak", Texture.oakSignPost)); + ALL_TEXTURES.put("sign_spruce", SignTexture.createSignTextureLoader("spruce", Texture.spruceSignPost)); + ALL_TEXTURES.put("sign_crimson", SignTexture.createSignTextureLoader("crimson", Texture.crimsonSignPost)); + ALL_TEXTURES.put("sign_warped", SignTexture.createSignTextureLoader("warped", Texture.warpedSignPost)); + ALL_TEXTURES.put("sign_mangrove", SignTexture.createSignTextureLoader("mangrove", Texture.mangroveSignPost)); + ALL_TEXTURES.put("sign_bamboo", SignTexture.createSignTextureLoader("bamboo", Texture.bambooSignPost)); + ALL_TEXTURES.put("sign_cherry", SignTexture.createSignTextureLoader("cherry", Texture.cherrySignPost)); + ALL_TEXTURES.put("sign_pale_oak", SignTexture.createSignTextureLoader("pale_oak", Texture.paleOakSignPost)); + + ALL_TEXTURES.put("hanging_sign_acacia", SignTexture.createHangingSignTextureLoader("acacia", Texture.acaciaHangingSign)); + ALL_TEXTURES.put("hanging_sign_birch", SignTexture.createHangingSignTextureLoader("birch", Texture.birchHangingSign)); + ALL_TEXTURES.put("hanging_sign_dark_oak", SignTexture.createHangingSignTextureLoader("dark_oak", Texture.darkOakHangingSign)); + ALL_TEXTURES.put("hanging_sign_jungle", SignTexture.createHangingSignTextureLoader("jungle", Texture.jungleHangingSign)); + ALL_TEXTURES.put("hanging_sign_oak", SignTexture.createHangingSignTextureLoader("oak", Texture.oakHangingSign)); + ALL_TEXTURES.put("hanging_sign_spruce", SignTexture.createHangingSignTextureLoader("spruce", Texture.spruceHangingSign)); + ALL_TEXTURES.put("hanging_sign_crimson", SignTexture.createHangingSignTextureLoader("crimson", Texture.crimsonHangingSign)); + ALL_TEXTURES.put("hanging_sign_warped", SignTexture.createHangingSignTextureLoader("warped", Texture.warpedHangingSign)); + ALL_TEXTURES.put("hanging_sign_mangrove", SignTexture.createHangingSignTextureLoader("mangrove", Texture.mangroveHangingSign)); + ALL_TEXTURES.put("hanging_sign_bamboo", SignTexture.createHangingSignTextureLoader("bamboo", Texture.bambooHangingSign)); + ALL_TEXTURES.put("hanging_sign_cherry", SignTexture.createHangingSignTextureLoader("cherry", Texture.cherryHangingSign)); + ALL_TEXTURES.put("hanging_sign_pale_oak", SignTexture.createHangingSignTextureLoader("pale_oak", Texture.paleOakHangingSign)); ALL_TEXTURES.put("cartography_table_side1", new SimpleTexture("assets/minecraft/textures/block/cartography_table_side1", @@ -3433,8 +3446,6 @@ public class TexturePackLoader { addSimpleTexture("assets/minecraft/textures/block/respawn_anchor_side2", Texture.respawnAnchorSide2); addSimpleTexture("assets/minecraft/textures/block/respawn_anchor_side3", Texture.respawnAnchorSide3); addSimpleTexture("assets/minecraft/textures/block/respawn_anchor_side4", Texture.respawnAnchorSide4); - addSimpleTexture("assets/minecraft/textures/entity/signs/crimson", Texture.crimsonSignPost); - addSimpleTexture("assets/minecraft/textures/entity/signs/warped", Texture.warpedSignPost); addSimpleTexture("assets/minecraft/textures/block/crimson_planks", Texture.crimsonPlanks); addSimpleTexture("assets/minecraft/textures/block/warped_planks", Texture.warpedPlanks); addSimpleTexture("assets/minecraft/textures/block/crimson_door_top", Texture.crimsonDoorTop); diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/HangingSignTextureAdapter26_2.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/HangingSignTextureAdapter26_2.java new file mode 100644 index 000000000..98c13676b --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/resources/texturepack/HangingSignTextureAdapter26_2.java @@ -0,0 +1,53 @@ +package se.llbit.chunky.resources.texturepack; + +import se.llbit.chunky.resources.BitmapImage; +import se.llbit.chunky.resources.LayeredResourcePacks; +import se.llbit.chunky.resources.Texture; + +import java.io.IOException; +import java.io.InputStream; +import java.util.function.Function; + +/** + * This texture loader is an adapter for the 26.2-snapshot-7 (or later) hanging sign textures. + * It converts pre-26.2-snapshot-7 hanging sign textures to the new format. + */ +public class HangingSignTextureAdapter26_2 extends TextureLoader { + private final Texture targetTexture; + private final Function originalTextureLoader; + + public HangingSignTextureAdapter26_2(Texture targetTexture, Function originalTextureLoader) { + this.targetTexture = targetTexture; + this.originalTextureLoader = originalTextureLoader; + } + + @Override + public boolean load(LayeredResourcePacks resourcePacks) { + Texture originalTexture = new Texture(); + if (!originalTextureLoader.apply(originalTexture).load(resourcePacks)) { + return false; + } + + int scale = originalTexture.getWidth() / 64; + BitmapImage newTexture = new BitmapImage(32 * scale, 32 * scale); + + newTexture.blit(originalTexture.getBitmap(), 0, 0, 4 * scale, 0, 20 * scale, 4 * scale); + newTexture.blit(originalTexture.getBitmap(), 0, 4 * scale, 4 * scale, 4 * scale, 24 * scale, 6 * scale); + newTexture.blit(originalTexture.getBitmap(), 20 * scale, 0, 14 * scale, 6 * scale, 26 * scale, 12 * scale); + newTexture.blit(originalTexture.getBitmap(), 0, 7 * scale, 24 * scale, 4 * scale, 40 * scale, 6 * scale); + newTexture.blit(originalTexture.getBitmap(), 16 * scale, 7 * scale, 0, 4 * scale, 4 * scale, 6 * scale); + newTexture.blit(originalTexture.getBitmap(), 0, 9 * scale, 36 * scale, 4 * scale, 20 * scale, 0); + newTexture.blit(originalTexture.getBitmap(), 22 * scale, 7 * scale, 0, 6 * scale, 9 * scale, 12 * scale); + newTexture.blit(originalTexture.getBitmap(), 0, 16 * scale, 0, 14 * scale, 32 * scale, 24 * scale); + newTexture.blit(originalTexture.getBitmap(), 2 * scale, 14 * scale, 2 * scale, 12 * scale, 16 * scale, 14 * scale); + newTexture.blit(originalTexture.getBitmap(), 2 * scale, 26 * scale, 16 * scale, 14 * scale, 30 * scale, 12 * scale); + + targetTexture.setTexture(newTexture); + return true; + } + + @Override + protected boolean load(InputStream imageStream) throws IOException, TextureFormatError { + return false; + } +} diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/SignTexture.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/SignTexture.java new file mode 100644 index 000000000..171aebfda --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/resources/texturepack/SignTexture.java @@ -0,0 +1,44 @@ +package se.llbit.chunky.resources.texturepack; + +import se.llbit.chunky.resources.Texture; + +public class SignTexture { + private SignTexture() { + } + + /** + * Create a texture loader for the given sign material that uses the 26.2 textures by default and falls back to + * older texture formats if they don't exist. + * + * @param material Sign material + * @return Texture loader for the given sign material + */ + public static TextureLoader createSignTextureLoader(String material, Texture texture) { + TextureLoader chaosCubedAdapter = "oak".equals(material) + ? new SignTextureAdapter26_2(texture, + t -> new AlternateTextures( + new SimpleTexture("assets/minecraft/textures/entity/signs/oak", t),// MC 1.14 + new SimpleTexture("assets/minecraft/textures/entity/sign", t),// MC 1.6 + new SimpleTexture("item/sign", t))) // before MC 1.6 + : new SignTextureAdapter26_2(texture, + t -> new SimpleTexture("assets/minecraft/textures/entity/signs/" + material, t)); + + return new AlternateTextures( + new SimpleTexture("assets/minecraft/textures/block/" + material + "_sign", texture), + chaosCubedAdapter); + } + + /** + * Create a texture loader for the given hanging sign material that uses the 26.2 textures by default and falls back to + * older texture formats if they don't exist. + * + * @param material Hanging sign material + * @return Texture loader for the given hanging sign material + */ + public static TextureLoader createHangingSignTextureLoader(String material, Texture texture) { + return new AlternateTextures( + new SimpleTexture("assets/minecraft/textures/block/" + material + "_hanging_sign", texture), + new HangingSignTextureAdapter26_2(texture, + t -> new SimpleTexture("assets/minecraft/textures/entity/signs/hanging/" + material, t))); + } +} diff --git a/chunky/src/java/se/llbit/chunky/resources/texturepack/SignTextureAdapter26_2.java b/chunky/src/java/se/llbit/chunky/resources/texturepack/SignTextureAdapter26_2.java new file mode 100644 index 000000000..ce83024d5 --- /dev/null +++ b/chunky/src/java/se/llbit/chunky/resources/texturepack/SignTextureAdapter26_2.java @@ -0,0 +1,52 @@ +package se.llbit.chunky.resources.texturepack; + +import se.llbit.chunky.resources.BitmapImage; +import se.llbit.chunky.resources.LayeredResourcePacks; +import se.llbit.chunky.resources.Texture; + +import java.io.IOException; +import java.io.InputStream; +import java.util.function.Function; + +/** + * This texture loader is an adapter for the 26.2-snapshot-7 (or later) sign textures. + * It converts pre-26.2-snapshot-7 sign textures to the new format. + */ +public class SignTextureAdapter26_2 extends TextureLoader { + private final Texture targetTexture; + private final Function originalTextureLoader; + + public SignTextureAdapter26_2(Texture targetTexture, Function originalTextureLoader) { + this.targetTexture = targetTexture; + this.originalTextureLoader = originalTextureLoader; + } + + @Override + public boolean load(LayeredResourcePacks resourcePacks) { + Texture originalTexture = new Texture(); + if (!originalTextureLoader.apply(originalTexture).load(resourcePacks)) { + return false; + } + + int scale = originalTexture.getWidth() / 64; + BitmapImage newTexture = new BitmapImage(32 * scale, 32 * scale); + + newTexture.blit(originalTexture.getBitmap(), 0, 2 * scale, 2 * scale, 2 * scale, 28 * scale, 14 * scale); + newTexture.blit(originalTexture.getBitmap(), 0, 16 * scale, 28 * scale, 2 * scale, 52 * scale, 14 * scale); + newTexture.blit(originalTexture.getBitmap(), 0, 0, 2 * scale, 0, 26 * scale, 2 * scale); + newTexture.blit(originalTexture.getBitmap(), 24 * scale, 16 * scale, 0, 2 * scale, 2 * scale, 14 * scale); + newTexture.blit(originalTexture.getBitmap(), 0, 28 * scale, 26 * scale, 2 * scale, 50 * scale, 0); + newTexture.blit(originalTexture.getBitmap(), 28 * scale, 0, 2 * scale, 16 * scale, 6 * scale, 30 * scale); + newTexture.blit(originalTexture.getBitmap(), 28 * scale, 16 * scale, 6 * scale, 16 * scale, 8 * scale, 30 * scale); + newTexture.blit(originalTexture.getBitmap(), 30 * scale, 16 * scale, 0, 16 * scale, 2 * scale, 30 * scale); + newTexture.blit(originalTexture.getBitmap(), 28 * scale, 30 * scale, 4 * scale, 16 * scale, 6 * scale, 14 * scale); + + targetTexture.setTexture(newTexture); + return true; + } + + @Override + protected boolean load(InputStream imageStream) throws IOException, TextureFormatError { + return false; + } +}