Skip to content

Commit

Permalink
Fix #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel-Martineau committed Apr 11, 2022
1 parent cbce942 commit 6f9f9e5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 136 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.18.2
yarn_mappings=1.18.2+build.2
loader_version=0.13.3
#Mod properties
mod_version=1.2.2
mod_version=1.2.3
maven_group=me.smartineau
archives_base_name=potions_hud_fabric
#Dependencies
Expand Down
100 changes: 0 additions & 100 deletions src/main/java/me/smartineau/HUD.java

This file was deleted.

3 changes: 0 additions & 3 deletions src/main/java/me/smartineau/PotionsHUDMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ public class PotionsHUDMod implements ModInitializer {

public static ConfigManager CONFIG_MANAGER;

public HUD hud;

public static void log(Level level, String message) {
LOGGER.log(level, "[" + MOD_NAME + "] " + message);
}

@Override
public void onInitialize() {
log(Level.INFO, "Initializing");
hud = new HUD();
CONFIG_MANAGER = new ConfigManager();
}

Expand Down
64 changes: 32 additions & 32 deletions src/main/java/me/smartineau/mixin/InGameHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,38 @@ public void renderStatusEffectOverlay(MatrixStack matrices) {
StatusEffectInstance statusEffectInstance = statusEffectsIterator.next();
StatusEffect statusEffect = statusEffectInstance.getEffectType();

if (statusEffectInstance.shouldShowIcon()) {
Sprite statusEffectSprite = statusEffectSpriteManager.getSprite(statusEffect);

statusEffectsRunnableList.add(() -> {
RenderSystem.setShaderTexture(0, statusEffectSprite.getAtlas().getId());
DrawableHelper.drawSprite(matrices, x, y, inGameHud.getZOffset(), spriteSize, spriteSize, statusEffectSprite);


int duration = statusEffectInstance.getDuration() / 20;
long mins = TimeUnit.SECONDS.toMinutes(duration);
long secs = duration - TimeUnit.MINUTES.toSeconds(mins);

String formattedDuration;
if (statusEffectInstance.isPermanent()) formattedDuration = "∞";
else if (mins == 0) formattedDuration = secs + " sec";
else formattedDuration = String.format("%d min, %d sec", mins, secs);

float textX = x + spriteSize + 3;
float textY = y + (spriteSize / 2f - textRenderer.fontHeight / 2.5f);

int color;
if (duration <= 5)
color = 0xFF5555;
else if (duration <= 15)
color = 0xFFAA00;
else if (duration <= 25)
color = 0xFFFF55;
else color = 0xFFFFFF;

textRenderer.draw(matrices, formattedDuration, textX, textY, color);
});
}
// if (statusEffectInstance.shouldShowIcon()) {
Sprite statusEffectSprite = statusEffectSpriteManager.getSprite(statusEffect);

statusEffectsRunnableList.add(() -> {
RenderSystem.setShaderTexture(0, statusEffectSprite.getAtlas().getId());
DrawableHelper.drawSprite(matrices, x, y, inGameHud.getZOffset(), spriteSize, spriteSize, statusEffectSprite);


int duration = statusEffectInstance.getDuration() / 20;
long mins = TimeUnit.SECONDS.toMinutes(duration);
long secs = duration - TimeUnit.MINUTES.toSeconds(mins);

String formattedDuration;
if (statusEffectInstance.isPermanent()) formattedDuration = "∞";
else if (mins == 0) formattedDuration = secs + " sec";
else formattedDuration = String.format("%d min, %d sec", mins, secs);

float textX = x + spriteSize + 3;
float textY = y + (spriteSize / 2f - textRenderer.fontHeight / 2.5f);

int color;
if (duration <= 5)
color = 0xFF5555;
else if (duration <= 15)
color = 0xFFAA00;
else if (duration <= 25)
color = 0xFFFF55;
else color = 0xFFFFFF;

textRenderer.draw(matrices, formattedDuration, textX, textY, color);
});
// }

i++;
}
Expand Down

0 comments on commit 6f9f9e5

Please sign in to comment.