From c24cae78c83f46ed7972e55ff1ccebaa14cc6a03 Mon Sep 17 00:00:00 2001 From: pkstDev Date: Mon, 18 Jul 2022 19:28:20 +0800 Subject: [PATCH] Fix plugin text render Bump version to 1.4.5 --- gradle.properties | 2 +- minepkg.toml | 2 +- .../plugin/context/BlockInfoPluginContext.java | 14 +++++++++----- .../plugin/context/EntityInfoPluginContext.java | 14 +++++++++----- .../hudium/client/gui/PlayerHud.java | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/gradle.properties b/gradle.properties index c78e885..f71e42b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ yarn_mappings = 1.19+build.4 loader_version = 0.14.8 # Mod Properties -mod_version = 1.4.4 +mod_version = 1.4.5 maven_group = dev.intelligentcreations archives_base_name = hudium-fabric mod_id = hudium diff --git a/minepkg.toml b/minepkg.toml index fdb712f..a015dd8 100644 --- a/minepkg.toml +++ b/minepkg.toml @@ -6,7 +6,7 @@ manifestVersion = 0 type = "mod" name = "hudium" description = "Tons of HUD tweaks including player stats, block/entity info, durability info, etc. No more pain installing that many mods!" - version = "1.4.4" + version = "1.4.5" platform = "fabric" license = "MIT License" source = "https://github.com/IntelligentCreations/Hudium/" diff --git a/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/BlockInfoPluginContext.java b/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/BlockInfoPluginContext.java index 7895ad5..ba3abcb 100644 --- a/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/BlockInfoPluginContext.java +++ b/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/BlockInfoPluginContext.java @@ -20,6 +20,7 @@ public class BlockInfoPluginContext implements PluginContext { private final TextRenderer textRenderer; private final BlockState state; private final BlockPos pos; + private final float startY; private int lines; private final HudiumConfig cfg = HudiumClient.CONFIG; @@ -30,7 +31,8 @@ protected BlockInfoPluginContext(MatrixStack matrices, float tickDelta, TextRenderer textRenderer, BlockState state, - BlockPos pos) { + BlockPos pos, + float startY) { this.matrices = matrices; this.client = client; this.player = player; @@ -38,6 +40,7 @@ protected BlockInfoPluginContext(MatrixStack matrices, this.textRenderer = textRenderer; this.state = state; this.pos = pos; + this.startY = startY; this.lines = 1; } @@ -47,8 +50,9 @@ public static BlockInfoPluginContext of(MatrixStack matrices, float tickDelta, TextRenderer textRenderer, BlockState state, - BlockPos pos) { - return new BlockInfoPluginContext(matrices, client, player, tickDelta, textRenderer, state, pos); + BlockPos pos, + float startY) { + return new BlockInfoPluginContext(matrices, client, player, tickDelta, textRenderer, state, pos, startY); } public MatrixStack getMatrices() { @@ -83,7 +87,7 @@ public BlockPos getPos() { public void renderText(Text text, int color) { boolean hasIcon = getState().getBlock().getPickStack(getPlayer().getWorld(), getPos(), getState()) != null && !(getState().getBlock() instanceof FluidBlock); - TextRendererUtil.renderText(textRenderer, matrices, text, hasIcon ? cfg.displayInfoX + 17 : cfg.displayInfoX, cfg.displayInfoY + 9 * lines, color); + TextRendererUtil.renderText(textRenderer, matrices, text, hasIcon ? cfg.displayInfoX + 17 : cfg.displayInfoX, cfg.displayInfoY + startY + 9 * (lines - 1), color); lines += 1; } @@ -91,7 +95,7 @@ public void renderText(Text text, int color) { public void renderText(String text, int color) { boolean hasIcon = getState().getBlock().getPickStack(getPlayer().getWorld(), getPos(), getState()) != null && !(getState().getBlock() instanceof FluidBlock); - TextRendererUtil.renderText(textRenderer, matrices, text, hasIcon ? cfg.displayInfoX + 17 : cfg.displayInfoX, cfg.displayInfoY + 9 * lines, color); + TextRendererUtil.renderText(textRenderer, matrices, text, hasIcon ? cfg.displayInfoX + 17 : cfg.displayInfoX, cfg.displayInfoY + startY + 9 * (lines - 1), color); lines += 1; } diff --git a/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/EntityInfoPluginContext.java b/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/EntityInfoPluginContext.java index ebb8b0e..403abf9 100644 --- a/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/EntityInfoPluginContext.java +++ b/src/main/java/dev/intelligentcreations/hudium/api/info/plugin/context/EntityInfoPluginContext.java @@ -17,6 +17,7 @@ public class EntityInfoPluginContext implements PluginContext { private final float tickDelta; private final TextRenderer textRenderer; private final Entity target; + private final float startY; private int lines; private final HudiumConfig cfg = HudiumClient.CONFIG; @@ -26,13 +27,15 @@ protected EntityInfoPluginContext(MatrixStack matrices, PlayerEntity player, float tickDelta, TextRenderer textRenderer, - Entity target) { + Entity target, + float startY) { this.matrices = matrices; this.client = client; this.player = player; this.tickDelta = tickDelta; this.textRenderer = textRenderer; this.target = target; + this.startY = startY; this.lines = 1; } @@ -41,8 +44,9 @@ public static EntityInfoPluginContext of(MatrixStack matrices, PlayerEntity player, float tickDelta, TextRenderer textRenderer, - Entity target) { - return new EntityInfoPluginContext(matrices, client, player, tickDelta, textRenderer, target); + Entity target, + float startY) { + return new EntityInfoPluginContext(matrices, client, player, tickDelta, textRenderer, target, startY); } public MatrixStack getMatrices() { @@ -70,12 +74,12 @@ public Entity getTarget() { } public void renderText(Text text, int color) { - TextRendererUtil.renderText(textRenderer, matrices, text, cfg.displayInfoX, cfg.displayInfoY + 9 * lines, color); + TextRendererUtil.renderText(textRenderer, matrices, text, cfg.displayInfoX, cfg.displayInfoY + startY + 9 * (lines - 1), color); lines += 1; } public void renderText(String text, int color) { - TextRendererUtil.renderText(textRenderer, matrices, text, cfg.displayInfoX, cfg.displayInfoY + 9 * lines, color); + TextRendererUtil.renderText(textRenderer, matrices, text, cfg.displayInfoX, cfg.displayInfoY + startY + 9 * (lines - 1), color); lines += 1; } diff --git a/src/main/java/dev/intelligentcreations/hudium/client/gui/PlayerHud.java b/src/main/java/dev/intelligentcreations/hudium/client/gui/PlayerHud.java index 780f47b..6df816e 100644 --- a/src/main/java/dev/intelligentcreations/hudium/client/gui/PlayerHud.java +++ b/src/main/java/dev/intelligentcreations/hudium/client/gui/PlayerHud.java @@ -119,7 +119,7 @@ public static boolean renderBlockInfo(MatrixStack matrices, MinecraftClient clie for (int q = 0; q < InfoPluginHandler.getPlugins().size(); q++) { if (InfoPluginHandler.getPlugins().get(q) instanceof BlockInfoPlugin plugin) { if (plugin.enabled()) { - BlockInfoPluginContext context = BlockInfoPluginContext.of(matrices, client, camera, tickDelta, textRenderer, state, bhr.getBlockPos()); + BlockInfoPluginContext context = BlockInfoPluginContext.of(matrices, client, camera, tickDelta, textRenderer, state, bhr.getBlockPos(), m); plugin.addInfo(context); m += 9 * (context.getLines() - 1); } @@ -148,7 +148,7 @@ public static boolean renderEntityInfo(MatrixStack matrices, MinecraftClient cli if (!InfoPluginHandler.getPlugins().isEmpty()) { for (int q = 0; q < InfoPluginHandler.getPlugins().size(); q++) { if (InfoPluginHandler.getPlugins().get(q) instanceof EntityInfoPlugin plugin) { - EntityInfoPluginContext context = EntityInfoPluginContext.of(matrices, client, camera, tickDelta, textRenderer, entity); + EntityInfoPluginContext context = EntityInfoPluginContext.of(matrices, client, camera, tickDelta, textRenderer, entity, m); plugin.addInfo(context); m += 9 * (context.getLines() - 1); }