Safe-cast to ServerPlayerEntity
This commit is contained in:
parent
ddfbf4593d
commit
50745d7923
|
@ -16,19 +16,20 @@ public abstract class MixinSlot {
|
||||||
// Denying item moving etc.
|
// Denying item moving etc.
|
||||||
@Inject(method = "canTakeItems(Lnet/minecraft/entity/player/PlayerEntity;)Z", at = @At(value = "HEAD"), cancellable = true)
|
@Inject(method = "canTakeItems(Lnet/minecraft/entity/player/PlayerEntity;)Z", at = @At(value = "HEAD"), cancellable = true)
|
||||||
private void canTakeItems(PlayerEntity playerEntity, CallbackInfoReturnable<Boolean> cir) {
|
private void canTakeItems(PlayerEntity playerEntity, CallbackInfoReturnable<Boolean> cir) {
|
||||||
ServerPlayerEntity player = (ServerPlayerEntity) playerEntity;
|
if (playerEntity instanceof ServerPlayerEntity player) {
|
||||||
ActionResult result = AuthEventHandler.onTakeItem(player);
|
ActionResult result = AuthEventHandler.onTakeItem(player);
|
||||||
|
|
||||||
if (result == ActionResult.FAIL) {
|
if (result == ActionResult.FAIL) {
|
||||||
// Canceling the item taking
|
// Canceling the item taking
|
||||||
player.networkHandler.sendPacket(
|
player.networkHandler.sendPacket(
|
||||||
new ScreenHandlerSlotUpdateS2CPacket(
|
new ScreenHandlerSlotUpdateS2CPacket(
|
||||||
-2,
|
-2,
|
||||||
0,
|
0,
|
||||||
player.getInventory().selectedSlot,
|
player.getInventory().selectedSlot,
|
||||||
player.getInventory().getStack(player.getInventory().selectedSlot))
|
player.getInventory().getStack(player.getInventory().selectedSlot))
|
||||||
);
|
);
|
||||||
cir.setReturnValue(false);
|
cir.setReturnValue(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue