aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-06 01:31:14 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-06 01:31:37 +0200
commit429eed9da370cbb12c1c2ccf822ef5bac900d221 (patch)
tree3eeedb0bd7de37b2c93a44e58ed61e3e070b0db7 /src/main/java/moe/nea
parentc3d32559e4132f163509143777ce8c6477a92c70 (diff)
downloadFirmament-429eed9da370cbb12c1c2ccf822ef5bac900d221.tar.gz
Firmament-429eed9da370cbb12c1c2ccf822ef5bac900d221.tar.bz2
Firmament-429eed9da370cbb12c1c2ccf822ef5bac900d221.zip
Add gender mod integration for custom armor
Closes https://github.com/nea89o/Firmament/issues/33
Diffstat (limited to 'src/main/java/moe/nea')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexturesInGenderMod.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexturesInGenderMod.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexturesInGenderMod.java
new file mode 100644
index 0000000..833c7d9
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchArmorTexturesInGenderMod.java
@@ -0,0 +1,41 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.mixins.custommodels;
+
+import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
+import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
+import com.llamalad7.mixinextras.sugar.Local;
+import com.wildfire.render.GenderArmorLayer;
+import moe.nea.firmament.features.texturepack.CustomGlobalArmorOverrides;
+import net.minecraft.item.ArmorItem;
+import net.minecraft.item.ArmorMaterial;
+import net.minecraft.item.ItemStack;
+import net.minecraft.registry.entry.RegistryEntry;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+
+@Mixin(GenderArmorLayer.class)
+public class PatchArmorTexturesInGenderMod {
+ @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/LivingEntity;FFFFFF)V",
+ at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ArmorItem;getMaterial()Lnet/minecraft/registry/entry/RegistryEntry;"))
+ private RegistryEntry<ArmorMaterial> replaceArmorMaterial(ArmorItem instance, Operation<RegistryEntry<ArmorMaterial>> original, @Local ItemStack chestplate) {
+ var entry = original.call(instance);
+ var overrides = CustomGlobalArmorOverrides.overrideArmor(chestplate);
+ if (overrides == null)
+ return entry;
+ var material = entry.value();
+ return RegistryEntry.of(new ArmorMaterial(
+ material.defense(),
+ material.enchantability(),
+ material.equipSound(),
+ material.repairIngredient(),
+ overrides,
+ material.toughness(),
+ material.knockbackResistance()
+ ));
+ }
+}