diff --git a/gradle.properties b/gradle.properties index e74047f..5cbe8c5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,15 +4,15 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.20.1 - yarn_mappings=1.20.1+build.2 - loader_version=0.14.21 + minecraft_version=1.20.3 + yarn_mappings=1.20.3+build.1 + loader_version=0.15.0 # Mod Properties - mod_version = 3.1.1 + mod_version = 3.1.2 maven_group = com.github.hhhzzzsss archives_base_name = song-player # Dependencies # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.83.1+1.20.1 + fabric_version=0.91.1+1.20.3 diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java b/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java index 9abaae5..b3259f3 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java @@ -41,7 +41,7 @@ public class FakePlayerEntity extends OtherClientPlayerEntity { capeY = getY(); capeZ = getZ(); - world.addEntity(getId(), this); + world.addEntity(this); } public void resetPlayerPosition() { diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/Util.java b/src/main/java/com/github/hhhzzzsss/songplayer/Util.java index effd97f..eb2453e 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/Util.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/Util.java @@ -6,7 +6,7 @@ import net.minecraft.command.CommandSource; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtString; -import net.minecraft.text.LiteralTextContent; +import net.minecraft.text.PlainTextContent; import net.minecraft.text.MutableText; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -216,19 +216,19 @@ public class Util { } public static MutableText getStyledText(String str, Style style) { - MutableText text = MutableText.of(new LiteralTextContent(str)); + MutableText text = MutableText.of(PlainTextContent.of(str)); text.setStyle(style); return text; } public static void setItemName(ItemStack stack, Text text) { - stack.getOrCreateSubNbt(ItemStack.DISPLAY_KEY).putString(ItemStack.NAME_KEY, Text.Serializer.toJson(text)); + stack.getOrCreateSubNbt(ItemStack.DISPLAY_KEY).putString(ItemStack.NAME_KEY, Text.Serialization.toJsonString(text)); } public static void setItemLore(ItemStack stack, Text... loreLines) { NbtList lore = new NbtList(); for (Text line : loreLines) { - lore.add(NbtString.of(Text.Serializer.toJson(line))); + lore.add(NbtString.of(Text.Serialization.toJsonString(line))); } stack.getOrCreateSubNbt(ItemStack.DISPLAY_KEY).put(ItemStack.LORE_KEY, lore); } diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/item/SongItemConfirmationScreen.java b/src/main/java/com/github/hhhzzzsss/songplayer/item/SongItemConfirmationScreen.java index 237ab90..12c273e 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/item/SongItemConfirmationScreen.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/item/SongItemConfirmationScreen.java @@ -54,7 +54,7 @@ public class SongItemConfirmationScreen extends Screen { @Override public void render(DrawContext context, int mouseX, int mouseY, float delta) { - this.renderBackground(context); + this.renderBackground(context, mouseX, mouseY, delta); context.drawCenteredTextWithShadow(textRenderer, this.title, this.width / 2, 40, 0xFFFFFF); diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientCommonNetworkHandlerMixin.java b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientCommonNetworkHandlerMixin.java new file mode 100644 index 0000000..eaed91c --- /dev/null +++ b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientCommonNetworkHandlerMixin.java @@ -0,0 +1,55 @@ +package com.github.hhhzzzsss.songplayer.mixin; + +import com.github.hhhzzzsss.songplayer.Config; +import com.github.hhhzzzsss.songplayer.SongPlayer; +import com.github.hhhzzzsss.songplayer.playing.SongHandler; +import com.github.hhhzzzsss.songplayer.playing.Stage; +import net.minecraft.client.network.ClientCommonNetworkHandler; +import net.minecraft.entity.EntityPose; +import net.minecraft.network.ClientConnection; +import net.minecraft.network.packet.Packet; +import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; +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; + +@Mixin(ClientCommonNetworkHandler.class) +public class ClientCommonNetworkHandlerMixin { + @Shadow + private final ClientConnection connection; + + public ClientCommonNetworkHandlerMixin() { + connection = null; + } + + @Inject(at = @At("HEAD"), method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) + private void onSendPacket(Packet packet, CallbackInfo ci) { + Stage stage = SongHandler.getInstance().stage; + + if (stage != null && packet instanceof PlayerMoveC2SPacket) { + if (!Config.getConfig().rotate) { + connection.send(new PlayerMoveC2SPacket.Full(stage.position.getX() + 0.5, stage.position.getY(), stage.position.getZ() + 0.5, SongPlayer.MC.player.getYaw(), SongPlayer.MC.player.getPitch(), true)); + if (SongPlayer.fakePlayer != null) { + SongPlayer.fakePlayer.copyStagePosAndPlayerLook(); + } + } + ci.cancel(); + } + else if (packet instanceof ClientCommandC2SPacket) { + ClientCommandC2SPacket.Mode mode = ((ClientCommandC2SPacket) packet).getMode(); + if (SongPlayer.fakePlayer != null) { + if (mode == ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY) { + SongPlayer.fakePlayer.setSneaking(true); + SongPlayer.fakePlayer.setPose(EntityPose.CROUCHING); + } + else if (mode == ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY) { + SongPlayer.fakePlayer.setSneaking(false); + SongPlayer.fakePlayer.setPose(EntityPose.STANDING); + } + } + } + } +} diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java index f3b9df2..2255d67 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java @@ -23,41 +23,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(ClientPlayNetworkHandler.class) public class ClientPlayNetworkHandlerMixin { - @Shadow - private final ClientConnection connection; - - public ClientPlayNetworkHandlerMixin() { - connection = null; - } - - @Inject(at = @At("HEAD"), method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) - private void onSendPacket(Packet packet, CallbackInfo ci) { - Stage stage = SongHandler.getInstance().stage; - - if (stage != null && packet instanceof PlayerMoveC2SPacket) { - if (!Config.getConfig().rotate) { - connection.send(new PlayerMoveC2SPacket.Full(stage.position.getX() + 0.5, stage.position.getY(), stage.position.getZ() + 0.5, SongPlayer.MC.player.getYaw(), SongPlayer.MC.player.getPitch(), true)); - if (SongPlayer.fakePlayer != null) { - SongPlayer.fakePlayer.copyStagePosAndPlayerLook(); - } - } - ci.cancel(); - } - else if (packet instanceof ClientCommandC2SPacket) { - ClientCommandC2SPacket.Mode mode = ((ClientCommandC2SPacket) packet).getMode(); - if (SongPlayer.fakePlayer != null) { - if (mode == ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY) { - SongPlayer.fakePlayer.setSneaking(true); - SongPlayer.fakePlayer.setPose(EntityPose.CROUCHING); - } - else if (mode == ClientCommandC2SPacket.Mode.RELEASE_SHIFT_KEY) { - SongPlayer.fakePlayer.setSneaking(false); - SongPlayer.fakePlayer.setPose(EntityPose.STANDING); - } - } - } - } - @Inject(at = @At("HEAD"), method = "sendChatMessage(Ljava/lang/String;)V", cancellable=true) private void onSendChatMessage(String content, CallbackInfo ci) { boolean isCommand = CommandProcessor.processChatMessage(content); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1972620..f3938a7 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -28,7 +28,7 @@ "depends": { "fabricloader": ">=0.14.11", "fabric": "*", - "minecraft": "1.20.x", + "minecraft": "1.20.3", "java": ">=17" }, "suggests": { diff --git a/src/main/resources/songplayer.mixins.json b/src/main/resources/songplayer.mixins.json index ccce863..98094e1 100644 --- a/src/main/resources/songplayer.mixins.json +++ b/src/main/resources/songplayer.mixins.json @@ -7,6 +7,7 @@ ], "client": [ "ChatInputSuggestorMixin", + "ClientCommonNetworkHandlerMixin", "ClientPlayerInteractionManagerAccessor", "ClientPlayNetworkHandlerAccessor", "ClientPlayNetworkHandlerMixin",