Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Oct 10, 2024
103 changes: 72 additions & 31 deletions src/main/java/tconstruct/armor/ArmorProxyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -259,7 +261,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:
Expand All @@ -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;
Kortako marked this conversation as resolved.
Show resolved Hide resolved
}

// ---

void renderArmorExtras(RenderPlayerEvent.SetArmorModel event) {

EntityPlayer player = event.entityPlayer;
Expand Down Expand Up @@ -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);
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/tconstruct/util/config/PHConstruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -482,6 +484,7 @@ public static void initProps(File location) {

// Looks
public static int connectedTexturesMode;
public static boolean showTravellerAccessories;

// dimensionblacklist
public static boolean slimeIslGenDim0Only;
Expand Down