aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/caelo/mixin
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-03-30 19:44:32 +0100
committerLinnea Gräf <nea@nea.moe>2024-03-30 19:44:32 +0100
commit0414b87e02e51b51cf9ef0c165e5ed61e5193160 (patch)
tree0d1a0144c44b252dcabc2c1d685a7d2b27e6adee /src/main/java/moe/nea/caelo/mixin
downloadveloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.tar.gz
veloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.tar.bz2
veloxcaelo-0414b87e02e51b51cf9ef0c165e5ed61e5193160.zip
Initial commit
Diffstat (limited to 'src/main/java/moe/nea/caelo/mixin')
-rw-r--r--src/main/java/moe/nea/caelo/mixin/PatchCustomItemModelCache.java42
1 files changed, 42 insertions, 0 deletions
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<CustomItemProperties> 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<CustomItemProperties> 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<CustomItemProperties> cir) {
+ OptifineCustomItemCache.storeNoCustomItemProperties(itemStack, type);
+ }
+
+
+} \ No newline at end of file