aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/custommodels/PatchHeadFeatureRenderer.java
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-11 01:58:23 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-11 01:58:23 +0200
commitfeca9c937be40bfed255e6574dea70d640fdafea (patch)
tree5ad4975ccfdc4b232e9a7fb34df4c01be4c2d441 /src/main/java/moe/nea/firmament/mixins/custommodels/PatchHeadFeatureRenderer.java
parent67cc7c22ac5f6873eb4549bc69db9f014c09c07f (diff)
downloadFirmament-feca9c937be40bfed255e6574dea70d640fdafea.tar.gz
Firmament-feca9c937be40bfed255e6574dea70d640fdafea.tar.bz2
Firmament-feca9c937be40bfed255e6574dea70d640fdafea.zip
Add custom head models
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/custommodels/PatchHeadFeatureRenderer.java')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/custommodels/PatchHeadFeatureRenderer.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchHeadFeatureRenderer.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchHeadFeatureRenderer.java
new file mode 100644
index 0000000..dca81b8
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchHeadFeatureRenderer.java
@@ -0,0 +1,50 @@
+/*
+ * 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 moe.nea.firmament.features.texturepack.BakedModelExtra;
+import net.minecraft.block.AbstractSkullBlock;
+import net.minecraft.block.Block;
+import net.minecraft.block.Blocks;
+import net.minecraft.client.render.entity.feature.HeadFeatureRenderer;
+import net.minecraft.client.render.entity.model.EntityModel;
+import net.minecraft.client.render.item.HeldItemRenderer;
+import net.minecraft.entity.LivingEntity;
+import net.minecraft.item.BlockItem;
+import net.minecraft.item.ItemStack;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+
+@Mixin(HeadFeatureRenderer.class)
+public class PatchHeadFeatureRenderer<T extends LivingEntity, M extends EntityModel<T>> {
+
+ @Shadow
+ @Final
+ private HeldItemRenderer heldItemRenderer;
+
+ @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/BlockItem;getBlock()Lnet/minecraft/block/Block;"))
+ private Block replaceSkull(BlockItem instance, Operation<Block> original, @Local ItemStack itemStack) {
+ var oldBlock = original.call(instance);
+ if (oldBlock instanceof AbstractSkullBlock) {
+ var bakedModel = this.heldItemRenderer.itemRenderer
+ .getModel(itemStack, null, null, 0);
+ if (bakedModel instanceof BakedModelExtra extra && extra.getHeadModel_firmament() != null)
+ return Blocks.ENCHANTING_TABLE; // Any non skull block. Let's choose the enchanting table because it is very distinct.
+ }
+ return oldBlock;
+ }
+
+
+
+
+}