Skip to content

Commit

Permalink
Avoid usage of Local in AbstractInventoryScreenMixin (#649)
Browse files Browse the repository at this point in the history
Fixes a weird crash in AOF7

Signed-off-by: unilock <[email protected]>
  • Loading branch information
unilock authored Dec 30, 2024
1 parent dfe74bb commit 9f2f05d
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.dafuqs.spectrum.mixin.client;

import com.llamalad7.mixinextras.sugar.*;
import de.dafuqs.spectrum.*;
import de.dafuqs.spectrum.api.status_effect.*;
import de.dafuqs.spectrum.registries.*;
Expand All @@ -9,6 +8,7 @@
import net.minecraft.util.*;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.*;

@Mixin(AbstractInventoryScreen.class)
public class AbstractInventoryScreenMixin {
Expand All @@ -20,16 +20,31 @@ public class AbstractInventoryScreenMixin {
@Unique
private static final Identifier DIVINITY_EFFECT_BACKGROUNDS = SpectrumCommon.locate("textures/gui/divinity_effect_backgrounds.png");

@Unique
private StatusEffectInstance effect;

@ModifyVariable(method = "drawStatusEffectBackgrounds", at = @At("STORE"))
public StatusEffectInstance storeEffect(StatusEffectInstance value) {
this.effect = value;
return value;
}

@ModifyArg(method = "drawStatusEffectBackgrounds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", ordinal = 0))
public Identifier modifyWideBackground(Identifier texture, @Local StatusEffectInstance effect) {
return getTexture(texture, effect);
public Identifier modifyWideBackground(Identifier texture) {
return getTexture(texture, this.effect);
}

@ModifyArg(method = "drawStatusEffectBackgrounds", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", ordinal = 1))
public Identifier modifyBackground(Identifier texture, @Local StatusEffectInstance effect) {
return getTexture(texture, effect);
public Identifier modifyBackground(Identifier texture) {
return getTexture(texture, this.effect);
}

@Inject(method = "drawStatusEffectBackgrounds", at = @At("TAIL"))
private void nullifyEffect(CallbackInfo ci) {
this.effect = null;
}

@Unique
private static Identifier getTexture(Identifier texture, StatusEffectInstance effect) {
var type = effect.getEffectType();

Expand Down

0 comments on commit 9f2f05d

Please sign in to comment.