diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0ef0696 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/.nb-gradle/ +/build/ +.gradle/ diff --git a/build.gradle b/build.gradle index 6fe2363..ccba9b0 100644 --- a/build.gradle +++ b/build.gradle @@ -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" @@ -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. diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/DurabilityViewer.java b/src/main/java/de/guntram/mcmod/durabilityviewer/DurabilityViewer.java index 388a023..47c356b 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/DurabilityViewer.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/DurabilityViewer.java @@ -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; diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java b/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java index 61d9a39..114edf4 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/client/gui/GuiItemDurability.java @@ -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; @@ -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 { @@ -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; @@ -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: @@ -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; @@ -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 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) { diff --git a/src/main/java/de/guntram/mcmod/durabilityviewer/handler/ConfigurationHandler.java b/src/main/java/de/guntram/mcmod/durabilityviewer/handler/ConfigurationHandler.java index bdd47e5..6913667 100644 --- a/src/main/java/de/guntram/mcmod/durabilityviewer/handler/ConfigurationHandler.java +++ b/src/main/java/de/guntram/mcmod/durabilityviewer/handler/ConfigurationHandler.java @@ -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) @@ -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(); @@ -63,4 +65,8 @@ public static Configuration getConfig() { public static String getConfigFileName() { return getInstance().configFileName; } + + public static boolean showEffectDuration() { + return getInstance().effectDuration; + } } diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 9e05f64..a1935de 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -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"],