From 9d0c90d2ac69b2cc216afc30ee97c0c22465784a Mon Sep 17 00:00:00 2001 From: ferriarnus <61201275+ferriarnus@users.noreply.github.com> Date: Sat, 20 Apr 2024 20:30:01 +0200 Subject: [PATCH 1/2] unhardcode quad constants --- .../client/model/ConduitTextureEmissiveQuadTransformer.java | 4 ++-- .../com/enderio/conduits/common/types/FluidClientData.java | 4 ++-- .../java/com/enderio/base/client/model/PaintedBlockModel.java | 4 ++-- .../enderio/base/client/model/PaintingQuadTransformer.java | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java b/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java index 73d8250ec1..1075b1a5ab 100644 --- a/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java +++ b/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java @@ -22,8 +22,8 @@ public void processInPlace(BakedQuad quad) { uv0[0] = (uv0[0] - quad.getSprite().getU0()) * newSprite.contents().width() / quad.getSprite().contents().width() + newSprite.getU0(); uv0[1] = (uv0[1] - quad.getSprite().getV0()) * newSprite.contents().height() / quad.getSprite().contents().height() + newSprite.getV0(); int[] packedTextureData = RenderUtil.packUV(uv0[0], uv0[1]); - quad.getVertices()[4 + i * 8] = packedTextureData[0]; - quad.getVertices()[5 + i * 8] = packedTextureData[1]; + quad.getVertices()[IQuadTransformer.UV0 + i * IQuadTransformer.STRIDE] = packedTextureData[0]; + quad.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1]; } } diff --git a/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java b/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java index ac372e1361..a65e1277e6 100644 --- a/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java +++ b/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java @@ -82,8 +82,8 @@ public void processInPlace(BakedQuad quad) { uv0[0] = (uv0[0] - quad.getSprite().getU0()) * sprite.contents().width() / quad.getSprite().contents().height() + sprite.getU0(); uv0[1] = (uv0[1] - quad.getSprite().getV0()) * sprite.contents().width() / quad.getSprite().contents().height() + sprite.getV0(); int[] packedTextureData = RenderUtil.packUV(uv0[0], uv0[1]); - quad.getVertices()[4 + i * STRIDE] = packedTextureData[0]; - quad.getVertices()[5 + i * STRIDE] = packedTextureData[1]; + quad.getVertices()[IQuadTransformer.UV0 + i * IQuadTransformer.STRIDE] = packedTextureData[0]; + quad.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1]; RenderUtil.putColorARGB(quad.getVertices(), i, clientExtension.getTintColor()); } } diff --git a/src/main/java/com/enderio/base/client/model/PaintedBlockModel.java b/src/main/java/com/enderio/base/client/model/PaintedBlockModel.java index ff2c9a7f3a..1bbd481877 100644 --- a/src/main/java/com/enderio/base/client/model/PaintedBlockModel.java +++ b/src/main/java/com/enderio/base/client/model/PaintedBlockModel.java @@ -341,8 +341,8 @@ protected BakedQuad paintQuad(BakedQuad toCopy, TextureAtlasSprite sprite, boole uv0[0] = (uv0[0] - toCopy.getSprite().getU0()) * sprite.contents().width() / toCopy.getSprite().contents().width() + sprite.getU0(); uv0[1] = (uv0[1] - toCopy.getSprite().getV0()) * sprite.contents().height() / toCopy.getSprite().contents().height() + sprite.getV0(); int[] packedTextureData = RenderUtil.packUV(uv0[0], uv0[1]); - copied.getVertices()[4 + i * 8] = packedTextureData[0]; - copied.getVertices()[5 + i * 8] = packedTextureData[1]; + copied.getVertices()[IQuadTransformer.UV0 + i * IQuadTransformer.STRIDE] = packedTextureData[0]; + copied.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1]; } return copied; } diff --git a/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java b/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java index d4f1422e28..abe52f9ca7 100644 --- a/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java +++ b/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java @@ -25,8 +25,8 @@ public void processInPlace(BakedQuad quad) { uv0[0] = (uv0[0] - quad.getSprite().getU0()) * sprite.contents().width() / quad.getSprite().contents().width() + sprite.getU0(); uv0[1] = (uv0[1] - quad.getSprite().getV0()) * sprite.contents().height() / quad.getSprite().contents().height() + sprite.getV0(); int[] packedTextureData = RenderUtil.packUV(uv0[0], uv0[1]); - quad.getVertices()[4 + i * STRIDE] = packedTextureData[0]; - quad.getVertices()[5 + i * STRIDE] = packedTextureData[1]; + quad.getVertices()[IQuadTransformer.UV0 + i * IQuadTransformer.STRIDE] = packedTextureData[0]; + quad.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1]; } } From e36162f8d7b2be7ece631384b0502b643ac3484d Mon Sep 17 00:00:00 2001 From: ferriarnus <61201275+ferriarnus@users.noreply.github.com> Date: Sat, 20 Apr 2024 23:36:20 +0200 Subject: [PATCH 2/2] also set sprite of the quad to the new sprite --- .../client/model/ConduitTextureEmissiveQuadTransformer.java | 2 +- .../com/enderio/conduits/common/types/FluidClientData.java | 1 + .../com/enderio/base/client/model/PaintingQuadTransformer.java | 1 + src/main/resources/META-INF/accesstransformer.cfg | 3 +++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java b/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java index 1075b1a5ab..02f453725a 100644 --- a/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java +++ b/src/conduits/java/com/enderio/conduits/client/model/ConduitTextureEmissiveQuadTransformer.java @@ -25,7 +25,7 @@ public void processInPlace(BakedQuad quad) { quad.getVertices()[IQuadTransformer.UV0 + i * IQuadTransformer.STRIDE] = packedTextureData[0]; quad.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1]; } - + quad.sprite = newSprite; } private static TextureAtlas blockAtlas() { diff --git a/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java b/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java index a65e1277e6..97843bd359 100644 --- a/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java +++ b/src/conduits/java/com/enderio/conduits/common/types/FluidClientData.java @@ -86,6 +86,7 @@ public void processInPlace(BakedQuad quad) { quad.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1]; RenderUtil.putColorARGB(quad.getVertices(), i, clientExtension.getTintColor()); } + quad.sprite = sprite; } } diff --git a/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java b/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java index abe52f9ca7..b921f42009 100644 --- a/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java +++ b/src/main/java/com/enderio/base/client/model/PaintingQuadTransformer.java @@ -28,6 +28,7 @@ public void processInPlace(BakedQuad quad) { quad.getVertices()[IQuadTransformer.UV0 + i * IQuadTransformer.STRIDE] = packedTextureData[0]; quad.getVertices()[IQuadTransformer.UV0 + 1 + i * IQuadTransformer.STRIDE] = packedTextureData[1]; } + quad.sprite = sprite; } private TextureAtlasSprite getSpriteForDirection(Direction direction) { diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 7b080ccad7..91186ef193 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -41,3 +41,6 @@ public net.minecraft.client.renderer.RenderStateShard name # name public net.minecraft.world.inventory.AbstractContainerMenu doClick(IILnet/minecraft/world/inventory/ClickType;Lnet/minecraft/world/entity/player/Player;)V # doClick # GhostSlot rendering for AbstractContainerScreen public net.minecraft.client.gui.screens.inventory.AbstractContainerScreen renderSlot(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/inventory/Slot;)V # renderSlot + +# Set quad sprite after changing it for conduits and painted blocks +public-f net.minecraft.client.renderer.block.model.BakedQuad sprite