Fix chat signatures desyncing when cancelling __on_player_message (#1778)
This commit is contained in:
1 parent
a29b84ec0d
commit
1a73edbf76
2 files changed
+14
-13
No files matched your search
@@ -2,6 +2,8 @@ package carpet.mixins;
|
||||
|
||||
import carpet.fakes.ServerPlayerInterface;
|
||||
import carpet.script.external.Vanilla;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
@@ -13,6 +15,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_MESSAGE;
|
||||
import static carpet.script.CarpetEventServer.Event.PLAYER_RESPAWNS;
|
||||
|
||||
@Mixin(PlayerList.class)
|
||||
@@ -26,6 +29,17 @@ public class PlayerList_scarpetEventsMixin
|
||||
PLAYER_RESPAWNS.onPlayerEvent(player);
|
||||
}
|
||||
|
||||
@Inject(method = "broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private void cancellableChatMessageEvent(PlayerChatMessage message, ServerPlayer player, ChatType.Bound params, CallbackInfo ci) {
|
||||
// having this earlier breaks signatures
|
||||
if (PLAYER_MESSAGE.isNeeded())
|
||||
{
|
||||
if (PLAYER_MESSAGE.onPlayerMessage(player, message.signedContent())) ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "respawn", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/level/ServerPlayer;initInventoryMenu()V"
|
||||
|
||||
Reference in new issue
Block a user