From 07256b68387e399e743fc098d250967a9ddedde7 Mon Sep 17 00:00:00 2001 From: glisco Date: Fri, 13 Sep 2024 18:52:42 +0200 Subject: [PATCH] stop deriving components if the map is somehow null to prevent crashing --- src/main/java/io/wispforest/owo/mixin/ext/ItemStackMixin.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/io/wispforest/owo/mixin/ext/ItemStackMixin.java b/src/main/java/io/wispforest/owo/mixin/ext/ItemStackMixin.java index 6792224d..47cb50b9 100644 --- a/src/main/java/io/wispforest/owo/mixin/ext/ItemStackMixin.java +++ b/src/main/java/io/wispforest/owo/mixin/ext/ItemStackMixin.java @@ -35,21 +35,25 @@ private void injectDerivedComponentMap(ItemConvertible item, int count, Componen // TODO: for some reason mixin doesn't like it if I put all the injects in one method. @Inject(method = "(Lnet/minecraft/item/ItemConvertible;ILnet/minecraft/component/ComponentMapImpl;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;postProcessComponents(Lnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER)) private void deriveComponents1(ItemConvertible item, int count, ComponentMapImpl components, CallbackInfo ci) { + if (owo$derivedMap == null) return; owo$derivedMap.derive((ItemStack)(Object) this); } @Inject(method = "applyChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;postProcessComponents(Lnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER)) private void deriveComponents2(ComponentChanges changes, CallbackInfo ci) { + if (owo$derivedMap == null) return; owo$derivedMap.derive((ItemStack)(Object) this); } @Inject(method = "applyUnvalidatedChanges", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;postProcessComponents(Lnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER)) private void deriveComponents3(ComponentChanges changes, CallbackInfo ci) { + if (owo$derivedMap == null) return; owo$derivedMap.derive((ItemStack)(Object) this); } @Inject(method = "applyComponentsFrom", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;postProcessComponents(Lnet/minecraft/item/ItemStack;)V", shift = At.Shift.AFTER)) private void deriveComponents4(ComponentMap components, CallbackInfo ci) { + if (owo$derivedMap == null) return; owo$derivedMap.derive((ItemStack)(Object) this); } }