Skip to content

Commit

Permalink
Fix plugin text render
Browse files Browse the repository at this point in the history
Bump version to 1.4.5
  • Loading branch information
Flamarine committed Jul 18, 2022
1 parent c95d660 commit c24cae7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion minepkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,14 +31,16 @@ 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;
this.tickDelta = tickDelta;
this.textRenderer = textRenderer;
this.state = state;
this.pos = pos;
this.startY = startY;
this.lines = 1;
}

Expand All @@ -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() {
Expand Down Expand Up @@ -83,15 +87,15 @@ 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;
}

@Override
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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() {
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit c24cae7

Please sign in to comment.