-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: resolve NPE in NetHandlerPlayClient#handleSpawnPlayer (#152)
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...java/club/sk1er/patcher/mixins/bugfixes/NetHandlerPlayClient_FixHandleSpawnPlayerNPE.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,35 @@ | ||
package club.sk1er.patcher.mixins.bugfixes; | ||
|
||
import net.minecraft.client.network.NetHandlerPlayClient; | ||
import net.minecraft.client.network.NetworkPlayerInfo; | ||
import net.minecraft.network.play.server.S0CPacketSpawnPlayer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.util.UUID; | ||
|
||
@Mixin(NetHandlerPlayClient.class) | ||
public abstract class NetHandlerPlayClient_FixHandleSpawnPlayerNPE { | ||
|
||
@Shadow | ||
public abstract NetworkPlayerInfo getPlayerInfo(UUID p_175102_1_); | ||
|
||
@Inject( | ||
method = "handleSpawnPlayer", | ||
cancellable = true, | ||
at = | ||
@At( | ||
value = "INVOKE", | ||
target = "Lnet/minecraft/network/PacketThreadUtil;checkThreadAndEnqueue(Lnet/minecraft/network/Packet;Lnet/minecraft/network/INetHandler;Lnet/minecraft/util/IThreadListener;)V", | ||
shift = At.Shift.AFTER | ||
)) | ||
private void patcher$fixHandleSpawnPlayerNPE(S0CPacketSpawnPlayer packetIn, CallbackInfo ci) { | ||
if (this.getPlayerInfo(packetIn.getPlayer()) == null) { | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
} |
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