From 07d8fc6d5259ae586e9c30a0971fe02a39ced10a Mon Sep 17 00:00:00 2001 From: samolego <34912839+samolego@users.noreply.github.com> Date: Thu, 28 Jul 2022 19:00:12 +0200 Subject: [PATCH] 1.19.1 --- .../samo_lego/taterzens/gui/EditorGUI.java | 2 +- ...GamePacketListenerImplMixin_MsgEditor.java | 38 +++++++++---------- ...mePacketListenerImplMixin_PacketFaker.java | 36 +++++++++--------- .../npc/commands/MinecraftCommand.java | 2 +- fabric/gradle.properties | 4 +- gradle.properties | 22 +++++------ 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/common/src/main/java/org/samo_lego/taterzens/gui/EditorGUI.java b/common/src/main/java/org/samo_lego/taterzens/gui/EditorGUI.java index 6de600eef..ac02844b4 100644 --- a/common/src/main/java/org/samo_lego/taterzens/gui/EditorGUI.java +++ b/common/src/main/java/org/samo_lego/taterzens/gui/EditorGUI.java @@ -199,7 +199,7 @@ private static void execute(ServerPlayer player, List commandTree) { player.closeContainer(); - player.getServer().getCommands().performCommand(player.createCommandSourceStack(), builder.toString()); + player.getServer().getCommands().performPrefixedCommand(player.createCommandSourceStack(), builder.toString()); } catch (IllegalArgumentException e) { player.sendSystemMessage(Component.literal(e.getMessage())); } diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java b/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java index 025a8c0c3..c0eb1ddd7 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java +++ b/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_MsgEditor.java @@ -3,55 +3,53 @@ import com.google.gson.JsonParseException; import com.mojang.brigadier.StringReader; import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.ChatSender; +import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; -import net.minecraft.network.protocol.game.ServerboundChatPacket; +import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.network.FilteredText; -import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.server.players.PlayerList; import org.samo_lego.taterzens.interfaces.ITaterzenEditor; import org.samo_lego.taterzens.npc.TaterzenNPC; 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.function.Predicate; + import static org.samo_lego.taterzens.Taterzens.config; import static org.samo_lego.taterzens.util.TextUtil.successText; import static org.samo_lego.taterzens.util.TextUtil.translate; -@Mixin(ServerGamePacketListenerImpl.class) +@Mixin(PlayerList.class) public class ServerGamePacketListenerImplMixin_MsgEditor { - @Shadow public ServerPlayer player; /** * Catches messages; if player is in * message edit mode, messages sent to chat * will be saved to taterzen instead. - * - * @param message message sent by player */ @Inject( - method = "handleChat(Lnet/minecraft/network/protocol/game/ServerboundChatPacket;Lnet/minecraft/server/network/FilteredText;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/network/protocol/game/ServerboundChatPacket;signedPreview()Z" - ), + method = "broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatSender;Lnet/minecraft/network/chat/ChatType$Bound;)V", + at = @At(value = "HEAD"), cancellable = true ) - private void onMessage(ServerboundChatPacket packet, FilteredText message, CallbackInfo ci) { - ITaterzenEditor editor = (ITaterzenEditor) this.player; + private void taterzens_chatBroadcast(PlayerChatMessage playerChatMessage, Predicate predicate, ServerPlayer player, ChatSender chatSender, ChatType.Bound bound, CallbackInfo ci) { + if (player == null) return; + + ITaterzenEditor editor = (ITaterzenEditor) player; TaterzenNPC taterzen = editor.getNpc(); - String msg = message.filtered(); + String msg = playerChatMessage.serverContent().getString(); - if (taterzen != null && ((ITaterzenEditor) this.player).getEditorMode() == ITaterzenEditor.EditorMode.MESSAGES && msg != null && !msg.startsWith("/")) { + if (taterzen != null && ((ITaterzenEditor) player).getEditorMode() == ITaterzenEditor.EditorMode.MESSAGES && msg != null && !msg.startsWith("/")) { if (msg.startsWith("delay")) { String[] split = msg.split(" "); if (split.length > 1) { try { int delay = Integer.parseInt(split[1]); taterzen.setMessageDelay(editor.getEditingMessageIndex(), delay); - this.player.displayClientMessage(successText("taterzens.command.message.delay", String.valueOf(delay)), false); + player.displayClientMessage(successText("taterzens.command.message.delay", String.valueOf(delay)), false); } catch (NumberFormatException ignored) { } @@ -76,7 +74,7 @@ private void onMessage(ServerboundChatPacket packet, FilteredText messag // Exiting the editor if(config.messages.exitEditorAfterMsgEdit) { - ((ITaterzenEditor) this.player).setEditorMode(ITaterzenEditor.EditorMode.NONE); + ((ITaterzenEditor) player).setEditorMode(ITaterzenEditor.EditorMode.NONE); (editor).setEditingMessageIndex(-1); player.displayClientMessage(translate("taterzens.command.equipment.exit").withStyle(ChatFormatting.LIGHT_PURPLE), false); } @@ -89,4 +87,4 @@ private void onMessage(ServerboundChatPacket packet, FilteredText messag ci.cancel(); } } -} +} \ No newline at end of file diff --git a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java b/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java index d45b292b6..9c11eca2e 100644 --- a/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java +++ b/common/src/main/java/org/samo_lego/taterzens/mixin/network/ServerGamePacketListenerImplMixin_PacketFaker.java @@ -1,9 +1,8 @@ package org.samo_lego.taterzens.mixin.network; import com.mojang.authlib.GameProfile; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; import net.minecraft.network.Connection; +import net.minecraft.network.PacketSendListener; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientboundAddPlayerPacket; import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket; @@ -16,6 +15,7 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.GameType; import net.minecraft.world.level.Level; +import org.jetbrains.annotations.Nullable; import org.samo_lego.taterzens.interfaces.ITaterzenEditor; import org.samo_lego.taterzens.mixin.accessors.ClientboundAddPlayerPacketAccessor; import org.samo_lego.taterzens.mixin.accessors.ClientboundPlayerInfoPacketAccessor; @@ -48,13 +48,18 @@ @Mixin(value = ServerGamePacketListenerImpl.class, priority = 900) public abstract class ServerGamePacketListenerImplMixin_PacketFaker { - @Shadow public ServerPlayer player; + @Shadow + public ServerPlayer player; @Final @Shadow public Connection connection; - @Shadow public abstract void send(Packet packet); + @Shadow + public abstract void send(Packet packet, @Nullable PacketSendListener packetSendListener); + + @Shadow + public abstract void send(Packet packet); @Unique private boolean taterzens$skipCheck; @@ -65,24 +70,21 @@ public abstract class ServerGamePacketListenerImplMixin_PacketFaker { /** * Changes entity type if entity is an instance of {@link TaterzenNPC}. - * - * @param packet packet to change - * @param listener */ @Inject( - method = "send(Lnet/minecraft/network/protocol/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V", + method = "send(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketSendListener;)V", at = @At( value = "INVOKE", - target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V" + target = "Lnet/minecraft/network/Connection;send(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketSendListener;)V" ), cancellable = true ) - private void changeEntityType(Packet packet, GenericFutureListener> listener, CallbackInfo ci) { + private void changeEntityType(Packet packet, PacketSendListener listener, CallbackInfo ci) { Level world = player.getLevel(); - if(packet instanceof ClientboundAddPlayerPacket && !this.taterzens$skipCheck) { + if (packet instanceof ClientboundAddPlayerPacket && !this.taterzens$skipCheck) { Entity entity = world.getEntity(((ClientboundAddPlayerPacketAccessor) packet).getId()); - if(!(entity instanceof TaterzenNPC npc)) + if (!(entity instanceof TaterzenNPC npc)) return; GameProfile profile = npc.getGameProfile(); @@ -91,13 +93,13 @@ private void changeEntityType(Packet packet, GenericFutureListener toRemove = new ArrayList<>(); - for(var iterator = taterzens$tablistQueue.values().iterator(); iterator.hasNext(); ) { + for (var iterator = taterzens$tablistQueue.values().iterator(); iterator.hasNext(); ) { var current = iterator.next(); - if(current.removeAt() > taterzens$queueTick) break; + if (current.removeAt() > taterzens$queueTick) break; iterator.remove(); toRemove.add(new ClientboundPlayerInfoPacket.PlayerUpdate(current.profile(), 0, GameType.SURVIVAL, current.displayName(), null)); } - if(toRemove.isEmpty()) return; + if (toRemove.isEmpty()) return; ClientboundPlayerInfoPacket taterzensRemovePacket = new ClientboundPlayerInfoPacket(REMOVE_PLAYER); //noinspection ConstantConditions diff --git a/common/src/main/java/org/samo_lego/taterzens/npc/commands/MinecraftCommand.java b/common/src/main/java/org/samo_lego/taterzens/npc/commands/MinecraftCommand.java index 39a8142e9..6141067d5 100644 --- a/common/src/main/java/org/samo_lego/taterzens/npc/commands/MinecraftCommand.java +++ b/common/src/main/java/org/samo_lego/taterzens/npc/commands/MinecraftCommand.java @@ -19,7 +19,7 @@ public MinecraftCommand() { @Override public void execute(TaterzenNPC npc, Player player) { - npc.getServer().getCommands().performCommand( + npc.getServer().getCommands().performPrefixedCommand( npc.createCommandSourceStack(), command.replaceAll(CLICKER_PLACEHOLDER, player.getGameProfile().getName())); } diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 77ab8d846..3d107c41c 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,2 +1,2 @@ -carpet_core_version=d27767ba98 -translations_api=1.4.14+1.19-rc2 +carpet_core_version=1.4.83 +translations_api=1.4.16+1.19 diff --git a/gradle.properties b/gradle.properties index 557b29cbf..2a36c3057 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,21 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx2G # Fabric Properties -minecraft_version=1.19 -yarn_mappings=1.19+build.4 -loader_version=0.14.7 +minecraft_version=1.19.1 +yarn_mappings=1.19.1+build.1 +loader_version=0.14.8 #Fabric api -fabric_version=0.56.0+1.19 -#Quilt Mappings -quilt_mappings=1 +fabric_version=0.58.5+1.19.1 #Forge -forge_version=41.0.1 -enable_forge=true +forge_version=42.0.0 +enable_forge=false # Mod Properties -mod_version=1.10.5 +mod_version=1.11.0 maven_group=org.samo_lego archives_base_name=taterzens +#Quilt Mappings +quilt_mappings=1 # Dependencies disguiselib_version=1.3.1 -c2b_version=1.1.4 -sgui_version=1.1.0+1.19 +c2b_version=1.2.1 +sgui_version=1.1.3+1.19.1