Several mixins implemented a Ref method only through a vanilla method of the same name. Released jars rename vanilla methods to intermediary names, so those Ref methods had no implementation there and threw AbstractMethodError: the armour display's durability, the status effects' icon and infinite checks, the SVG texture size and the pre-1.21.6 matrix stack's push and pop. With Mojang's names the same happens in development (1.21.4 crashed on the title screen). Each mixin now shadows the vanilla method and implements the Ref method by calling it. Points common at the Ref renames this needs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
73 lines
2.1 KiB
Java
73 lines
2.1 KiB
Java
package org.saturnclient.impl.mixins;
|
|
|
|
import org.saturnclient.common.ref.asset.IdentifierRef;
|
|
import org.saturnclient.common.ref.asset.SpriteRef;
|
|
import org.saturnclient.common.ref.game.EffectRef;
|
|
//? if <1.21.9
|
|
//import org.saturnclient.saturnclient.SaturnClient;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Shadow;
|
|
|
|
import net.minecraft.client.gui.Gui;
|
|
import net.minecraft.world.effect.MobEffect;
|
|
import net.minecraft.world.effect.MobEffectInstance;
|
|
import net.minecraft.core.Holder;
|
|
import net.minecraft.resources.Identifier;
|
|
|
|
@Mixin(MobEffectInstance.class)
|
|
public abstract class StatusEffectMixin implements EffectRef {
|
|
|
|
@Shadow
|
|
public abstract boolean showIcon();
|
|
|
|
@Shadow
|
|
public abstract boolean isInfiniteDuration();
|
|
|
|
@Shadow
|
|
public abstract int getDuration();
|
|
|
|
@Shadow
|
|
public abstract Holder<MobEffect> getEffect();
|
|
|
|
// EffectRef's methods delegate to MobEffectInstance's, whose names production renames.
|
|
@Override
|
|
public boolean shouldShowIcon() {
|
|
return showIcon();
|
|
}
|
|
|
|
@Override
|
|
public boolean isInfinite() {
|
|
return isInfiniteDuration();
|
|
}
|
|
|
|
@Override
|
|
public SpriteRef getIcon() {
|
|
// 1.21.9 changed the GUI atlas, so newer versions draw the effect's texture (getIconId) instead.
|
|
//? if >=1.21.9 {
|
|
return null;
|
|
//?} else if >=1.21.6 {
|
|
//return (SpriteRef) SaturnClient.client.getGuiSprites().getSprite((Gui.getMobEffectSprite(getEffect())));
|
|
//?} else
|
|
//return (SpriteRef) SaturnClient.client.getMobEffectTextures().get(getEffect());
|
|
}
|
|
|
|
// Before 1.21.6 there's no InGameHud.getEffectTexture; getIcon's sprite is used there instead.
|
|
//? if >=1.21.6 {
|
|
@Override
|
|
public IdentifierRef getIconId() {
|
|
Identifier id = Gui.getMobEffectSprite(getEffect());
|
|
|
|
return IdentifierRef.of(id.getNamespace(), "textures/" + id.getPath() + ".png");
|
|
}
|
|
//?}
|
|
|
|
@Override
|
|
public String getInfiniteText() {
|
|
return "∞";
|
|
}
|
|
|
|
@Override
|
|
public int getDurationSeconds() {
|
|
return getDuration() / 20; // ticks → seconds
|
|
}
|
|
} |