diff options
Diffstat (limited to 'src/main/java/eu/olli')
-rw-r--r-- | src/main/java/eu/olli/cowlection/listener/DungeonsListener.java | 21 | ||||
-rw-r--r-- | src/main/java/eu/olli/cowlection/listener/PlayerListener.java | 26 |
2 files changed, 46 insertions, 1 deletions
diff --git a/src/main/java/eu/olli/cowlection/listener/DungeonsListener.java b/src/main/java/eu/olli/cowlection/listener/DungeonsListener.java index a45d451..67f7b83 100644 --- a/src/main/java/eu/olli/cowlection/listener/DungeonsListener.java +++ b/src/main/java/eu/olli/cowlection/listener/DungeonsListener.java @@ -80,12 +80,31 @@ public class DungeonsListener { reforge = reforge.substring(0, modifierSuffix); } int reforgeInItemName = originalItemName.indexOf(reforge); + if (reforgeInItemName == -1 && reforge.equals("Light") && extraAttributes.getString("id").startsWith("HEAVY_")) { + // special case: heavy armor with light reforge + reforgeInItemName = originalItemName.indexOf("Heavy"); + } if (reforgeInItemName > 0 && !originalItemName.contains(EnumChatFormatting.STRIKETHROUGH.toString())) { // we have a reforged item! strike through reforge in item name and remove any essence upgrades (✪) String grayedOutFormatting = "" + EnumChatFormatting.GRAY + EnumChatFormatting.STRIKETHROUGH; + + int reforgeLength = reforge.length(); + String reforgePrefix = null; + // special cases for reforge + item name + if (reforge.equals("Heavy") && extraAttributes.getString("id").startsWith("HEAVY_")) { + reforgePrefix = "Extremely "; + } else if (reforge.equals("Light") && extraAttributes.getString("id").startsWith("HEAVY_")) { + reforgePrefix = "Not So "; + } else if (reforge.equals("Wise") && extraAttributes.getString("id").startsWith("WISE_")) { + reforgePrefix = "Very "; + } + if (reforgePrefix != null) { + reforgeInItemName -= reforgePrefix.length(); + reforgeLength = reforgePrefix.length() - 1; + } StringBuffer modifiedItemName = new StringBuffer(originalItemName) .insert(reforgeInItemName, grayedOutFormatting) - .insert(reforgeInItemName + reforge.length() + grayedOutFormatting.length(), originalItemName.substring(0, reforgeInItemName)); + .insert(reforgeInItemName + reforgeLength + grayedOutFormatting.length(), originalItemName.substring(0, reforgeInItemName)); // remove essence upgrade indicators (✪) String essenceUpgradeIndicator = EnumChatFormatting.GOLD + "✪"; int essenceModifier = modifiedItemName.indexOf(essenceUpgradeIndicator); diff --git a/src/main/java/eu/olli/cowlection/listener/PlayerListener.java b/src/main/java/eu/olli/cowlection/listener/PlayerListener.java index 3f5ee33..1c7710d 100644 --- a/src/main/java/eu/olli/cowlection/listener/PlayerListener.java +++ b/src/main/java/eu/olli/cowlection/listener/PlayerListener.java @@ -9,6 +9,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiChest; import net.minecraft.client.gui.inventory.GuiInventory; +import net.minecraft.enchantment.Enchantment; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.ContainerChest; @@ -18,7 +19,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; import net.minecraftforge.client.event.GuiScreenEvent; +import net.minecraftforge.common.util.Constants; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent; @@ -55,6 +58,29 @@ public class PlayerListener { if (e.itemStack == null || e.toolTip == null) { return; } + // remove unnecessary tooltip entries: dyed leather armor + NBTTagCompound nbtDisplay = e.itemStack.getSubCompound("display", false); + if (nbtDisplay != null && nbtDisplay.hasKey("color", Constants.NBT.TAG_INT)) { + if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips) { + e.toolTip.removeIf(line -> line.startsWith("Color: #")); + } else { + e.toolTip.removeIf(line -> line.equals(EnumChatFormatting.ITALIC + StatCollector.translateToLocal("item.dyed"))); + } + } + + // remove unnecessary tooltip entries: enchantments (already added via lore) + NBTTagList enchantments = e.itemStack.getEnchantmentTagList(); + if (enchantments != null) { + for (int enchantmentNr = 0; enchantmentNr < enchantments.tagCount(); ++enchantmentNr) { + int enchantmentId = enchantments.getCompoundTagAt(enchantmentNr).getShort("id"); + int enchantmentLevel = enchantments.getCompoundTagAt(enchantmentNr).getShort("lvl"); + + if (Enchantment.getEnchantmentById(enchantmentId) != null) { + e.toolTip.remove(Enchantment.getEnchantmentById(enchantmentId).getTranslatedName(enchantmentLevel)); + } + } + } + if (!MooConfig.showAdvancedTooltips && !Keyboard.isKeyDown(Keyboard.KEY_LMENU)) { return; } |