Allow hiding of Traveller's Gear accessories (gloves and belt) through config option and Translucency enchant (#125)

* Add configuration option to hide Traveller's gear accessories from displaying on player model

* Make Translucency I and II enchantments from WG work properly with traveler's accessories (must enchant from book for now)

* Update src/main/java/tconstruct/armor/ArmorProxyClient.java

Co-authored-by: Alexander Anishin <[email protected]>

* Implement suggested style changes

* spotless fix

---------

Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Alexander Anishin <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-10-10 09:06:21 +02:00
1 parent 46e26a7168
commit 3ffa69d254
3 files changed
+69 -37

No files matched your search

@@ -3,6 +3,8 @@ package tconstruct.armor;
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.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
@@ -259,7 +261,7 @@ public class ArmorProxyClient extends ArmorProxyCommon {
ArmorProxyClient.belt.isChild = event.renderer.modelBipedMain.isChild;
ArmorProxyClient.belt.isSneak = event.renderer.modelBipedMain.isSneak;
renderArmorExtras(event);
if (PHConstruct.showTravellerAccessories) renderArmorExtras(event);
break;
case 3:
@@ -271,6 +273,32 @@ public class ArmorProxyClient extends ArmorProxyCommon {
}
}
// --- 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 getTranslucencyLevel(ItemStack stack) {
int translucent = getTranslucentID();
if (translucent > 0) return EnchantmentHelper.getEnchantmentLevel(translucent, stack);
else return 0;
}
// ---
void renderArmorExtras(RenderPlayerEvent.SetArmorModel event) {
EntityPlayer player = event.entityPlayer;
@@ -313,40 +341,46 @@ public class ArmorProxyClient extends ArmorProxyCommon {
// 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 (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);
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 (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 (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);
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 (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);
}
}
}
}
@@ -4,6 +4,7 @@ import java.lang.ref.WeakReference;
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,8 @@ public class ArmorExtended implements IInventory {
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;
}
// ---
@@ -250,6 +250,8 @@ public class PHConstruct {
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 class PHConstruct {
// Looks
public static int connectedTexturesMode;
public static boolean showTravellerAccessories;
// dimensionblacklist
public static boolean slimeIslGenDim0Only;