Skip to content

Commit

Permalink
stop deriving components if the map is somehow null to prevent crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
gliscowo committed Sep 13, 2024
1 parent c024ee0 commit 07256b6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/io/wispforest/owo/mixin/ext/ItemStackMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<init>(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);
}
}

0 comments on commit 07256b6

Please sign in to comment.