aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/mixin
diff options
context:
space:
mode:
authorSHsuperCM <shsupercm@gmail.com>2021-08-22 20:38:54 +0300
committerSHsuperCM <shsupercm@gmail.com>2021-08-22 20:38:54 +0300
commit69a8dd26d808c49c865575486849ee9093c82e0e (patch)
tree921f7d1ece5391600fddf25d03e4675f6e2a7ec6 /src/main/java/shcm/shsupercm/fabric/citresewn/mixin
parent38c7261feca5e3a054109d58794dc62615a09557 (diff)
downloadCITResewn-69a8dd26d808c49c865575486849ee9093c82e0e.tar.gz
CITResewn-69a8dd26d808c49c865575486849ee9093c82e0e.tar.bz2
CITResewn-69a8dd26d808c49c865575486849ee9093c82e0e.zip
Started work on baking CITItem and started item mixin
Diffstat (limited to 'src/main/java/shcm/shsupercm/fabric/citresewn/mixin')
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ItemRendererMixin.java25
-rw-r--r--src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelOverrideListMixin.java27
2 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ItemRendererMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ItemRendererMixin.java
new file mode 100644
index 0000000..1679188
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ItemRendererMixin.java
@@ -0,0 +1,25 @@
+package shcm.shsupercm.fabric.citresewn.mixin;
+
+import net.minecraft.client.render.item.ItemRenderer;
+import net.minecraft.client.render.model.BakedModel;
+import net.minecraft.entity.LivingEntity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import shcm.shsupercm.fabric.citresewn.CITResewn;
+
+@Mixin(ItemRenderer.class)
+public class ItemRendererMixin {
+ @Inject(method = "getHeldItemModel", cancellable = true, at = @At("RETURN"))
+ public void getItemModel(ItemStack stack, World world, LivingEntity entity, int seed, CallbackInfoReturnable<BakedModel> cir) {
+ if (CITResewn.INSTANCE.activeCITs == null)
+ return;
+
+ BakedModel citModel = CITResewn.INSTANCE.activeCITs.getItemModel(stack, cir.getReturnValue());
+ if (citModel != null)
+ cir.setReturnValue(citModel);
+ }
+}
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelOverrideListMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelOverrideListMixin.java
new file mode 100644
index 0000000..0bfaa4e
--- /dev/null
+++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ModelOverrideListMixin.java
@@ -0,0 +1,27 @@
+package shcm.shsupercm.fabric.citresewn.mixin;
+
+import net.minecraft.client.render.model.BakedModel;
+import net.minecraft.client.render.model.ModelLoader;
+import net.minecraft.client.render.model.UnbakedModel;
+import net.minecraft.client.render.model.json.JsonUnbakedModel;
+import net.minecraft.client.render.model.json.ModelOverride;
+import net.minecraft.client.render.model.json.ModelOverrideList;
+import net.minecraft.util.Identifier;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import shcm.shsupercm.fabric.citresewn.CITResewn;
+
+import java.util.function.Function;
+
+@Mixin(ModelOverrideList.class)
+public class ModelOverrideListMixin {
+ @Inject(method = "bakeOverridingModel", at = @At("RETURN"))
+ public void onBakeOverridingModel(ModelLoader loader, JsonUnbakedModel parent, Function<Identifier, UnbakedModel> unbakedModelGetter, ModelOverride override, CallbackInfoReturnable<BakedModel> cir) {
+ if (cir.getReturnValue() != null) {
+ String[] split = override.getModelId().getPath().split("/");
+ CITResewn.INSTANCE.bakedOverridesCache.put(cir.getReturnValue(), split[split.length - 1]);
+ }
+ }
+}