From 800e2216b19d678b7409b7cbc462242c8a6e53bf Mon Sep 17 00:00:00 2001 From: Kortako Date: Sat, 5 Oct 2024 19:05:15 -0700 Subject: [PATCH 1/5] Add configuration option to hide Traveller's gear accessories from displaying on player model --- src/main/java/tconstruct/armor/ArmorProxyClient.java | 2 +- src/main/java/tconstruct/util/config/PHConstruct.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index 15d1439589..e798492a7f 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -259,7 +259,7 @@ public void adjustArmor(RenderPlayerEvent.SetArmorModel event) { ArmorProxyClient.belt.isChild = event.renderer.modelBipedMain.isChild; ArmorProxyClient.belt.isSneak = event.renderer.modelBipedMain.isSneak; - renderArmorExtras(event); + if (PHConstruct.showTravellerAccessories) renderArmorExtras(event); break; case 3: diff --git a/src/main/java/tconstruct/util/config/PHConstruct.java b/src/main/java/tconstruct/util/config/PHConstruct.java index 2391e7ad5c..aa6639f762 100644 --- a/src/main/java/tconstruct/util/config/PHConstruct.java +++ b/src/main/java/tconstruct/util/config/PHConstruct.java @@ -250,6 +250,8 @@ public static void initProps(File location) { conTexMode.comment = "0 = disabled, 1 = enabled, 2 = enabled + ignore stained glass meta"; connectedTexturesMode = conTexMode.getInt(2); + showTravellerAccessories = config.get("Looks", "Show Traveller Gear Accessories", true).getBoolean(true); + // dimension blacklist cfgForbiddenDim = config .get( @@ -482,6 +484,7 @@ public static void initProps(File location) { // Looks public static int connectedTexturesMode; + public static boolean showTravellerAccessories; // dimensionblacklist public static boolean slimeIslGenDim0Only; From 601c156331c5b6ee9fd96431be36a75e99d1ca3b Mon Sep 17 00:00:00 2001 From: Kortako Date: Mon, 7 Oct 2024 21:51:35 -0700 Subject: [PATCH 2/5] Make Translucency I and II enchantments from WG work properly with traveler's accessories (must enchant from book for now) --- .../tconstruct/armor/ArmorProxyClient.java | 101 ++++++++++++------ 1 file changed, 71 insertions(+), 30 deletions(-) diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index e798492a7f..1e74fb883a 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -3,12 +3,14 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.model.ModelBiped; +import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagList; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.client.event.FOVUpdateEvent; @@ -271,6 +273,39 @@ public void adjustArmor(RenderPlayerEvent.SetArmorModel event) { } } + // --- WitchingGadgets Translucent II enchant support + private static int translucentID = -6; + + public static int getTranslucentID() { + if (translucentID == -6) setTranslucentID(); + return translucentID; + } + + private static void setTranslucentID() { + for (Enchantment ench : Enchantment.enchantmentsList) { + if (ench != null && ench.getName().equals("enchantment.wg.invisibleGear")) { + translucentID = ench.effectId; + return; + } + } + translucentID = -1; + } + + public static int isTranslucent(ItemStack stack) { + int translucent = getTranslucentID(); + NBTTagList stackEnch = stack.getEnchantmentTagList(); + if (translucent >= 0 && stackEnch != null) { + for (int i = 0; i < stackEnch.tagCount(); i++) { + int id = stackEnch.getCompoundTagAt(i).getInteger("id"); + int lvl = stackEnch.getCompoundTagAt(i).getInteger("lvl"); + if (id == translucent) return lvl; + } + } + return 0; + } + + // --- + void renderArmorExtras(RenderPlayerEvent.SetArmorModel event) { EntityPlayer player = event.entityPlayer; @@ -313,40 +348,46 @@ void renderArmorExtras(RenderPlayerEvent.SetArmorModel event) { // TPlayerStats stats = TPlayerStats.get(player); ArmorExtended armor = ArmorProxyClient.armorExtended; // TODO: Do this for every player, not just the client if (armor != null && armor.inventory[1] != null) { - Item item = armor.inventory[1].getItem(); - ModelBiped model = item.getArmorModel(player, armor.inventory[1], 4); - - if (item instanceof IAccessoryModel) { - this.mc.getTextureManager() - .bindTexture(((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); - model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); - model.render( - player, - limbSwingMod, - limbSwing, - pitch, - yawRotation - yawOffset, - bodyRotation, - zeropointsixtwofive); + if (isTranslucent(armor.inventory[1]) != 2 + && !(player.isInvisible() && isTranslucent(armor.inventory[1]) > 0)) { + Item item = armor.inventory[1].getItem(); + ModelBiped model = item.getArmorModel(player, armor.inventory[1], 4); + + if (item instanceof IAccessoryModel) { + this.mc.getTextureManager() + .bindTexture(((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); + model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); + model.render( + player, + limbSwingMod, + limbSwing, + pitch, + yawRotation - yawOffset, + bodyRotation, + zeropointsixtwofive); + } } } if (armor != null && armor.inventory[3] != null) { - Item item = armor.inventory[3].getItem(); - ModelBiped model = item.getArmorModel(player, armor.inventory[3], 5); - - if (item instanceof IAccessoryModel) { - this.mc.getTextureManager() - .bindTexture(((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); - model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); - model.render( - player, - limbSwingMod, - limbSwing, - pitch, - yawRotation - yawOffset, - bodyRotation, - zeropointsixtwofive); + if (isTranslucent(armor.inventory[3]) != 2 + && !(player.isInvisible() && isTranslucent(armor.inventory[3]) > 0)) { + Item item = armor.inventory[3].getItem(); + ModelBiped model = item.getArmorModel(player, armor.inventory[3], 5); + + if (item instanceof IAccessoryModel) { + this.mc.getTextureManager() + .bindTexture(((IAccessoryModel) item).getWearbleTexture(player, armor.inventory[1], 1)); + model.setLivingAnimations(player, limbSwingMod, limbSwing, partialTick); + model.render( + player, + limbSwingMod, + limbSwing, + pitch, + yawRotation - yawOffset, + bodyRotation, + zeropointsixtwofive); + } } } } From f48d76b5d97202ec729b737c08ad2da7606d6121 Mon Sep 17 00:00:00 2001 From: Kortako Date: Wed, 9 Oct 2024 16:39:54 -0700 Subject: [PATCH 3/5] Update src/main/java/tconstruct/armor/ArmorProxyClient.java Co-authored-by: Alexander Anishin --- src/main/java/tconstruct/armor/ArmorProxyClient.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index 1e74fb883a..e22199cbf1 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -293,15 +293,7 @@ private static void setTranslucentID() { public static int isTranslucent(ItemStack stack) { int translucent = getTranslucentID(); - NBTTagList stackEnch = stack.getEnchantmentTagList(); - if (translucent >= 0 && stackEnch != null) { - for (int i = 0; i < stackEnch.tagCount(); i++) { - int id = stackEnch.getCompoundTagAt(i).getInteger("id"); - int lvl = stackEnch.getCompoundTagAt(i).getInteger("lvl"); - if (id == translucent) return lvl; - } - } - return 0; + return EnchantmentHelper.getEnchantmentLevel(translucent, stack); } // --- From 6673840634f0858377a3858b1a337c6768d10e6a Mon Sep 17 00:00:00 2001 From: Kortako Date: Wed, 9 Oct 2024 16:49:06 -0700 Subject: [PATCH 4/5] Implement suggested style changes --- .../java/tconstruct/armor/ArmorProxyClient.java | 16 ++++++++++------ .../tconstruct/armor/player/ArmorExtended.java | 13 +++++-------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index e22199cbf1..8879234a7b 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -4,6 +4,7 @@ import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.model.ModelBiped; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -291,9 +292,12 @@ private static void setTranslucentID() { translucentID = -1; } - public static int isTranslucent(ItemStack stack) { + public static int getTranslucencyLevel(ItemStack stack) { int translucent = getTranslucentID(); - return EnchantmentHelper.getEnchantmentLevel(translucent, stack); + if (translucent > 0) + return EnchantmentHelper.getEnchantmentLevel(translucent, stack); + else + return 0; } // --- @@ -340,8 +344,8 @@ void renderArmorExtras(RenderPlayerEvent.SetArmorModel event) { // TPlayerStats stats = TPlayerStats.get(player); ArmorExtended armor = ArmorProxyClient.armorExtended; // TODO: Do this for every player, not just the client if (armor != null && armor.inventory[1] != null) { - if (isTranslucent(armor.inventory[1]) != 2 - && !(player.isInvisible() && isTranslucent(armor.inventory[1]) > 0)) { + if (getTranslucencyLevel(armor.inventory[1]) != 2 + && !(player.isInvisible() && getTranslucencyLevel(armor.inventory[1]) > 0)) { Item item = armor.inventory[1].getItem(); ModelBiped model = item.getArmorModel(player, armor.inventory[1], 4); @@ -362,8 +366,8 @@ void renderArmorExtras(RenderPlayerEvent.SetArmorModel event) { } if (armor != null && armor.inventory[3] != null) { - if (isTranslucent(armor.inventory[3]) != 2 - && !(player.isInvisible() && isTranslucent(armor.inventory[3]) > 0)) { + if (getTranslucencyLevel(armor.inventory[3]) != 2 + && !(player.isInvisible() && getTranslucencyLevel(armor.inventory[3]) > 0)) { Item item = armor.inventory[3].getItem(); ModelBiped model = item.getArmorModel(player, armor.inventory[3], 5); diff --git a/src/main/java/tconstruct/armor/player/ArmorExtended.java b/src/main/java/tconstruct/armor/player/ArmorExtended.java index 501a34b48b..6714688540 100644 --- a/src/main/java/tconstruct/armor/player/ArmorExtended.java +++ b/src/main/java/tconstruct/armor/player/ArmorExtended.java @@ -4,6 +4,7 @@ import java.util.UUID; import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.ai.attributes.IAttributeInstance; @@ -218,14 +219,10 @@ private static void setSoulBoundID() { public static boolean isSoulBounded(ItemStack stack) { int soulBound = getSoulBoundID(); - NBTTagList stackEnch = stack.getEnchantmentTagList(); - if (soulBound >= 0 && stackEnch != null) { - for (int i = 0; i < stackEnch.tagCount(); i++) { - int id = stackEnch.getCompoundTagAt(i).getInteger("id"); - if (id == soulBound) return true; - } - } - return false; + if(soulBound > 0) + return EnchantmentHelper.getEnchantmentLevel(soulBound, stack) > 0; + else + return false; } // --- From 82d0f6611179a9fe4d136d53e2b0fb6095d191cb Mon Sep 17 00:00:00 2001 From: Kortako Date: Wed, 9 Oct 2024 18:58:55 -0700 Subject: [PATCH 5/5] spotless fix --- src/main/java/tconstruct/armor/ArmorProxyClient.java | 7 ++----- src/main/java/tconstruct/armor/player/ArmorExtended.java | 6 ++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/tconstruct/armor/ArmorProxyClient.java b/src/main/java/tconstruct/armor/ArmorProxyClient.java index 8879234a7b..2e5bc8c57c 100644 --- a/src/main/java/tconstruct/armor/ArmorProxyClient.java +++ b/src/main/java/tconstruct/armor/ArmorProxyClient.java @@ -11,7 +11,6 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagList; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.client.event.FOVUpdateEvent; @@ -294,10 +293,8 @@ private static void setTranslucentID() { public static int getTranslucencyLevel(ItemStack stack) { int translucent = getTranslucentID(); - if (translucent > 0) - return EnchantmentHelper.getEnchantmentLevel(translucent, stack); - else - return 0; + if (translucent > 0) return EnchantmentHelper.getEnchantmentLevel(translucent, stack); + else return 0; } // --- diff --git a/src/main/java/tconstruct/armor/player/ArmorExtended.java b/src/main/java/tconstruct/armor/player/ArmorExtended.java index 6714688540..ce8d7ec86a 100644 --- a/src/main/java/tconstruct/armor/player/ArmorExtended.java +++ b/src/main/java/tconstruct/armor/player/ArmorExtended.java @@ -219,10 +219,8 @@ private static void setSoulBoundID() { public static boolean isSoulBounded(ItemStack stack) { int soulBound = getSoulBoundID(); - if(soulBound > 0) - return EnchantmentHelper.getEnchantmentLevel(soulBound, stack) > 0; - else - return false; + if (soulBound > 0) return EnchantmentHelper.getEnchantmentLevel(soulBound, stack) > 0; + else return false; } // ---