From 0414b87e02e51b51cf9ef0c165e5ed61e5193160 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Sat, 30 Mar 2024 19:44:32 +0100 Subject: Initial commit --- .../nea/caelo/mixin/PatchCustomItemModelCache.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/moe/nea/caelo/mixin/PatchCustomItemModelCache.java (limited to 'src/main/java/moe/nea/caelo/mixin') diff --git a/src/main/java/moe/nea/caelo/mixin/PatchCustomItemModelCache.java b/src/main/java/moe/nea/caelo/mixin/PatchCustomItemModelCache.java new file mode 100644 index 0000000..afeafef --- /dev/null +++ b/src/main/java/moe/nea/caelo/mixin/PatchCustomItemModelCache.java @@ -0,0 +1,42 @@ +package moe.nea.caelo.mixin; + +import moe.nea.caelo.optifine.OptifineCustomItemCache; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.optifine.CustomItemProperties; +import net.optifine.CustomItems; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +@Pseudo +@Mixin(value = CustomItems.class, remap = false) +public class PatchCustomItemModelCache { + + @SuppressWarnings("InvalidInjectorMethodSignature") + @Inject(method = "getCustomItemProperties", at = @At("HEAD"), cancellable = true) + private static void overrideCustomItemProperties( + ItemStack itemStack, int type, + CallbackInfoReturnable cir) { + OptifineCustomItemCache.retrieveCacheHit(itemStack, type, cir); + } + + @Inject(method = "getCustomItemProperties", at = @At(value = "RETURN", ordinal = 2), + locals = LocalCapture.CAPTURE_FAILHARD) + private static void storeCustomItemProperties( + ItemStack itemStack, int type, CallbackInfoReturnable cir, + Item item, int itemId, CustomItemProperties[] cips, int i, CustomItemProperties cip) { + OptifineCustomItemCache.storeCustomItemProperties(itemStack, type, cip); + } + + @Inject(method = "getCustomItemProperties", at = @At(value = "RETURN", ordinal = 3)) + private static void storeCustomItemProperties( + ItemStack itemStack, int type, CallbackInfoReturnable cir) { + OptifineCustomItemCache.storeNoCustomItemProperties(itemStack, type); + } + + +} \ No newline at end of file -- cgit