Skip to content
This repository has been archived by the owner on Jun 23, 2024. It is now read-only.

Commit

Permalink
update to forge 2387, version 1.2, show buff/debuff durations as well…
Browse files Browse the repository at this point in the history
… (configurable)
  • Loading branch information
gbl committed Jul 20, 2017
1 parent aaa33a3 commit ec70969
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.nb-gradle/
/build/
.gradle/
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.12-forge14.21.0.2375-1.0.0"
version = "1.12-forge14.21.1.2387-1.2"
group = "de.guntram.mcmod.DurabilityViewer" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "DurabilityViewer"

Expand All @@ -21,7 +21,7 @@ compileJava {
}

minecraft {
version = "1.12-14.21.0.2375"
version = "1.12-14.21.1.2387"
runDir = "run"

// the mappings can be changed at any time, and must be in the following format.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class DurabilityViewer
{
public static final String MODID = "durabilityviewer";
public static final String VERSION = "1.1.0";
public static final String VERSION = "1.2";

@Mod.Instance("durabilityviewer")
public static DurabilityViewer instance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package de.guntram.mcmod.durabilityviewer.client.gui;

import com.google.common.collect.Ordering;
import de.guntram.mcmod.durabilityviewer.handler.ConfigurationHandler;
import de.guntram.mcmod.durabilityviewer.itemindicator.InventorySlotsIndicator;
import de.guntram.mcmod.durabilityviewer.itemindicator.ItemIndicator;
import de.guntram.mcmod.durabilityviewer.itemindicator.ItemCountIndicator;
import de.guntram.mcmod.durabilityviewer.itemindicator.ItemDamageIndicator;
import de.guntram.mcmod.durabilityviewer.sound.ItemBreakingWarner;
import java.util.Collection;
import net.minecraft.item.ItemBow;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -22,6 +24,8 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

public class GuiItemDurability extends Gui
{
Expand Down Expand Up @@ -100,7 +104,7 @@ public void onRender(final RenderGameOverlayEvent.Post event) {
if (!visible
|| event.isCanceled()
|| minecraft.player.capabilities.isCreativeMode
|| event.getType()!=RenderGameOverlayEvent.ElementType.EXPERIENCE)
|| event.getType()!=RenderGameOverlayEvent.ElementType.POTION_ICONS)
return;

EntityPlayer effectivePlayer = (EntityPlayer) minecraft.player;
Expand Down Expand Up @@ -135,7 +139,7 @@ public void onRender(final RenderGameOverlayEvent.Post event) {

int totalHeight=(toolsSize.height > armorSize.height ? toolsSize.height : armorSize.height);
int totalWidth =(toolsSize.width > armorSize.width ? toolsSize.width : armorSize.width);
int xposArmor, xposTools, ypos;
int xposArmor, xposTools, ypos, xpos;

switch (ConfigurationHandler.getCorner()) {
case TOP_LEFT:
Expand All @@ -146,7 +150,7 @@ public void onRender(final RenderGameOverlayEvent.Post event) {
case TOP_RIGHT:
xposArmor=screensize.getScaledWidth()-5-armorSize.width;
xposTools=screensize.getScaledWidth()-5-armorSize.width-toolsSize.width;
ypos=30; // below buff/debuff effects
ypos=60; // below buff/debuff effects
break;
case BOTTOM_LEFT:
xposArmor=5;
Expand All @@ -170,6 +174,30 @@ public void onRender(final RenderGameOverlayEvent.Post event) {
this.renderItems(xposTools, ypos, true, ConfigurationHandler.getCorner().isRight(), toolsSize.width, invSlots, mainHand, offHand, arrows);

RenderHelper.disableStandardItemLighting();

if (ConfigurationHandler.showEffectDuration()) {
// a lot of this is copied from net/minecraft/client/gui/GuiIngame.java
Collection<PotionEffect> collection = minecraft.player.getActivePotionEffects();
int posGood=0, posBad=0;
for (PotionEffect potioneffect : Ordering.natural().reverse().sortedCopy(collection)) {
if (potioneffect.doesShowParticles()) {
Potion potion = potioneffect.getPotion();
xpos=screensize.getScaledWidth();
if (potion.isBeneficial()) {
posGood+=25; xpos-=posGood; ypos=15;
} else {
posBad+=25; xpos-=posBad; ypos=41;
}
int duration=potioneffect.getDuration();
String show;
if (duration > 1200)
show=(duration/1200)+"m";
else
show=(duration/20)+"s";
fontRenderer.drawString(show, xpos+2, ypos, ItemIndicator.color_yellow);
}
}
}
}

private RenderSize renderItems(int xpos, int ypos, boolean reallyDraw, boolean numbersLeft, int maxWidth, ItemIndicator... items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class ConfigurationHandler

private int corner=0;
private int color= 5;
private boolean effectDuration;

public static ConfigurationHandler getInstance() {
if (instance==null)
Expand All @@ -43,6 +44,7 @@ public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
private void loadConfig() {
corner=config.getInt("HUD Corner", Configuration.CATEGORY_CLIENT, corner, 0, 3, "Corner 0 to 3 - bottom right, bottom left, top right, top left");
color=config.getInt("Tooltip Color", Configuration.CATEGORY_CLIENT, color, 0, 15, "Minecraft Color 0 .. 15");
effectDuration=config.getBoolean("Effect Duration", Configuration.CATEGORY_CLIENT, true, "Show effect durations");
tooltipColor=TextFormatting.fromColorIndex(color);
if (config.hasChanged())
config.save();
Expand All @@ -63,4 +65,8 @@ public static Configuration getConfig() {
public static String getConfigFileName() {
return getInstance().configFileName;
}

public static boolean showEffectDuration() {
return getInstance().effectDuration;
}
}
4 changes: 2 additions & 2 deletions src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"modid": "durabilityviewer",
"name": "Durability Viewer",
"description": "Creates a HUD that shows current item durability, arrow count, and inventory slots",
"version": "1.1.0",
"mcversion": "1.11.2",
"version": "${version}",
"mcversion": "${mcversion}",
"url": "",
"updateUrl": "",
"authorList": ["Giselbaer"],
Expand Down

0 comments on commit ec70969

Please sign in to comment.