From 43bbb7d5bcef829b6a1bc1c16e4a962e55c8f0f2 Mon Sep 17 00:00:00 2001 From: UselessBullets <80850784+UselessBullets@users.noreply.github.com> Date: Wed, 27 Sep 2023 18:07:43 -0500 Subject: [PATCH] Commented And Cleaned Up Code --- .../java/turniplabs/halplibe/helper/TextureHelper.java | 7 +++++-- .../halplibe/mixin/mixins/RenderEngineMixin.java | 1 + .../java/turniplabs/halplibe/util/TextureHandler.java | 10 +++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/turniplabs/halplibe/helper/TextureHelper.java b/src/main/java/turniplabs/halplibe/helper/TextureHelper.java index df5d71e..6bc20b9 100644 --- a/src/main/java/turniplabs/halplibe/helper/TextureHelper.java +++ b/src/main/java/turniplabs/halplibe/helper/TextureHelper.java @@ -1,5 +1,6 @@ package turniplabs.halplibe.helper; +import net.minecraft.core.Global; import net.minecraft.core.block.Block; import turniplabs.halplibe.util.TextureHandler; @@ -16,10 +17,12 @@ public class TextureHelper { public static Map textureAtlasWidths = new HashMap<>(); static { + // Assign Default Resolutions textureDestinationResolutions.put("/terrain.png", 16); textureDestinationResolutions.put("/gui/items.png", 16); - textureAtlasWidths.put("/terrain.png", 32); - textureAtlasWidths.put("/gui/items.png", 32); + // Assign Default Atlas Widths + textureAtlasWidths.put("/terrain.png", Global.TEXTURE_ATLAS_WIDTH_TILES); + textureAtlasWidths.put("/gui/items.png", Global.TEXTURE_ATLAS_WIDTH_TILES); } @Deprecated diff --git a/src/main/java/turniplabs/halplibe/mixin/mixins/RenderEngineMixin.java b/src/main/java/turniplabs/halplibe/mixin/mixins/RenderEngineMixin.java index 72fe76b..7ae5ee8 100644 --- a/src/main/java/turniplabs/halplibe/mixin/mixins/RenderEngineMixin.java +++ b/src/main/java/turniplabs/halplibe/mixin/mixins/RenderEngineMixin.java @@ -24,6 +24,7 @@ public abstract class RenderEngineMixin { private void initDynamicTextures(CallbackInfo ci) { Minecraft mc = Minecraft.getMinecraft(Minecraft.class); for (String key: TextureHelper.textureDestinationResolutions.keySet()) { + // Updates atlas resolution references GL11.glBindTexture(3553, thisAsRenderEngine.getTexture(key)); int destinationResolution = GL11.glGetTexLevelParameteri(3553, 0, 4096) / TextureHelper.textureAtlasWidths.get(key); TextureHelper.textureDestinationResolutions.put(key, destinationResolution); diff --git a/src/main/java/turniplabs/halplibe/util/TextureHandler.java b/src/main/java/turniplabs/halplibe/util/TextureHandler.java index 803a902..2bc9373 100644 --- a/src/main/java/turniplabs/halplibe/util/TextureHandler.java +++ b/src/main/java/turniplabs/halplibe/util/TextureHandler.java @@ -21,7 +21,6 @@ public class TextureHandler extends DynamicTexture { private final byte[] frames; private int elapsedTicks = 0; private static final Minecraft fakeMc; - // End Resolution/source Resolutions private final float scale; public TextureHandler(String textureName, String animationSource, int textureIndex, int resolution, int width) { @@ -35,7 +34,8 @@ public TextureHandler(String textureName, String animationSource, int textureInd this.defaultResolution = defaultResolution; BufferedImage image = Textures.readImage(mc.texturePackList.selectedTexturePack.getResourceAsStream(animationSource)); this.resolution = image.getWidth(); - this.scale = getScale(mc, textureName, resolution); + // Scaling factor from source resolution to destination resolution + this.scale = getScale(textureName, resolution); this.width = width; @@ -75,17 +75,17 @@ public void update() { public String getTextureName() { return this.textureName; } - public static float getScale(Minecraft mc, String textureName, int resolution){ + public static float getScale(String textureName, int resolution){ if (TextureHelper.textureDestinationResolutions.get(textureName) != null){ return (float)TextureHelper.textureDestinationResolutions.get(textureName)/resolution; } return 1f; } - public static int getAtlasResolution(String textureName, int resolution){ + public static int getAtlasResolution(String textureName, int defaultResolution){ if (TextureHelper.textureDestinationResolutions.get(textureName) != null){ return TextureHelper.textureDestinationResolutions.get(textureName); } - return resolution; + return defaultResolution; } static {