Fixed players kicked from server when trying to use an ability

This commit is contained in:
Sollace 2024-10-28 15:47:04 +00:00
parent 0603ebf281
commit e67954f370
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 3 additions and 1 deletions

View file

@ -9,4 +9,6 @@ import net.minecraft.network.codec.PacketCodec;
public final class MsgCancelPlayerAbility { public final class MsgCancelPlayerAbility {
public static final MsgCancelPlayerAbility INSTANCE = new MsgCancelPlayerAbility(); public static final MsgCancelPlayerAbility INSTANCE = new MsgCancelPlayerAbility();
public static final PacketCodec<ByteBuf, MsgCancelPlayerAbility> PACKET_CODEC = PacketCodec.unit(INSTANCE); public static final PacketCodec<ByteBuf, MsgCancelPlayerAbility> PACKET_CODEC = PacketCodec.unit(INSTANCE);
private MsgCancelPlayerAbility() {}
} }

View file

@ -48,7 +48,7 @@ public record MsgPlayerAbility<T extends Hit> (
power.onQuickAction(player, type, data); power.onQuickAction(player, type, data);
} else { } else {
if (data.filter(data -> power.apply(player, data)).isEmpty()) { if (data.filter(data -> power.apply(player, data)).isEmpty()) {
Channel.CANCEL_PLAYER_ABILITY.sendToPlayer(new MsgCancelPlayerAbility(), sender); Channel.CANCEL_PLAYER_ABILITY.sendToPlayer(MsgCancelPlayerAbility.INSTANCE, sender);
} }
} }
} }