-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mixin to fix NPE from Waystones (#112)
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
1 parent
d922b2d
commit 39400f0
Showing
3 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/org/embeddedt/archaicfix/mixins/common/waystones/MixinItemWarpStone.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |