Skip to content

Commit

Permalink
Add mixin to fix NPE from Waystones (#112)
Browse files Browse the repository at this point in the history
AE2 calls getDisplayDamage from the server thread during world startup,
and the warpstone attempts to load the client player from that method.
Since the client player isn't present at that point, it NPEs when
it tries to read the player's data.
  • Loading branch information
jeremiahwinsley committed Feb 10, 2024
1 parent d922b2d commit 39400f0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/embeddedt/archaicfix/asm/Mixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public enum Mixin {

common_foodplus_MixinUpdater(Side.COMMON, Phase.LATE, require(TargetedMod.FOODPLUS).and(m -> ArchaicConfig.disableFoodPlusUpdates), "foodplus.MixinUpdater"),

common_waystones_MixinItemWarpStone(Side.COMMON, Phase.LATE, require(TargetedMod.WAYSTONES), "waystones.MixinItemWarpStone"),

/** This mixin will ostensibly be unnecessary after DragonAPI V31b */
common_dragonapi_MixinReikaWorldHelper(Side.COMMON, Phase.LATE, m -> DragonAPIHelper.isVersionInInclusiveRange(0, 'a', 31, 'b') && !Boolean.valueOf(System.getProperty("archaicFix.disableFastReikaWorldHelper", "false")), "dragonapi.MixinReikaWorldHelper"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public enum TargetedMod {
AM2("ArsMagica2", "arsmagica2"),
FOODPLUS("FoodPlus", "FoodPlus"),
DIVERSITY("Diversity", "diversity"),
WAYSTONES("Waystones", "waystones"),
AOA("AdventOfAscension", "nevermine")
;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.embeddedt.archaicfix.mixins.common.waystones;

import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.item.ItemStack;
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;

@Pseudo
@Mixin(targets = "net.blay09.mods.waystones.item.ItemWarpStone")
public class MixinItemWarpStone {
@Inject(method = "getDisplayDamage", at = @At("HEAD"), cancellable = true)
public void getDisplayDamage(ItemStack itemStack, CallbackInfoReturnable<Integer> cir) {
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
cir.setReturnValue(0);
cir.cancel();
}
}
}

0 comments on commit 39400f0

Please sign in to comment.