diff --git a/gradle.properties b/gradle.properties index b17758c..aa75a3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,9 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.18.2 - yarn_mappings=1.18.2+build.2 - loader_version=0.13.3 + minecraft_version=1.19 + yarn_mappings=1.19+build.1 + loader_version=0.14.6 # Mod Properties mod_version = 1.2.1 @@ -14,4 +14,4 @@ org.gradle.jvmargs=-Xmx1G # 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.47.10+1.18.2 + fabric_version=0.55.2+1.19 diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java b/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java index d0c914e..963de98 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/CommandProcessor.java @@ -337,7 +337,10 @@ public class CommandProcessor { public boolean processCommand(String args) { if (args.length() > 0) { SongPlayer.creativeCommand = args; - SongPlayer.addChatMessage("§6Set creative command to " + SongPlayer.creativeCommand); + if (SongPlayer.creativeCommand.startsWith("/")) { + SongPlayer.creativeCommand = SongPlayer.creativeCommand.substring(1); + } + SongPlayer.addChatMessage("§6Set creative command to /" + SongPlayer.creativeCommand); return true; } else { @@ -359,7 +362,10 @@ public class CommandProcessor { public boolean processCommand(String args) { if (args.length() > 0) { SongPlayer.survivalCommand = args; - SongPlayer.addChatMessage("§6Set survival command to " + SongPlayer.survivalCommand); + if (SongPlayer.survivalCommand.startsWith("/")) { + SongPlayer.survivalCommand = SongPlayer.survivalCommand.substring(1); + } + SongPlayer.addChatMessage("§6Set survival command to /" + SongPlayer.survivalCommand); return true; } else { diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java b/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java index 72fcbca..ebb1d90 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java @@ -10,7 +10,7 @@ public class FakePlayerEntity extends OtherClientPlayerEntity { ClientWorld world = SongPlayer.MC.world; public FakePlayerEntity() { - super(SongPlayer.MC.world, SongPlayer.MC.player.getGameProfile()); + super(SongPlayer.MC.world, SongPlayer.MC.player.getGameProfile(), SongPlayer.MC.player.getPublicKey()); copyStagePosAndPlayerLook(); diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/Freecam.java b/src/main/java/com/github/hhhzzzsss/songplayer/Freecam.java index 50ed130..7332d48 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/Freecam.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/Freecam.java @@ -2,7 +2,6 @@ package com.github.hhhzzzsss.songplayer; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; -import net.minecraft.text.LiteralText; import net.minecraft.util.math.Vec3d; public class Freecam { diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/SongPlayer.java b/src/main/java/com/github/hhhzzzsss/songplayer/SongPlayer.java index 010f911..34b80c1 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/SongPlayer.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/SongPlayer.java @@ -7,7 +7,8 @@ import com.github.hhhzzzsss.songplayer.song.Song; import net.fabricmc.api.ModInitializer; import net.minecraft.client.MinecraftClient; -import net.minecraft.text.LiteralText; +import net.minecraft.text.LiteralTextContent; +import net.minecraft.text.Text; public class SongPlayer implements ModInitializer { @@ -41,6 +42,6 @@ public class SongPlayer implements ModInitializer { } public static void addChatMessage(String message) { - MC.player.sendMessage(new LiteralText(message), false); + MC.player.sendMessage(Text.of(message), false); } } diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java index 36fc5d2..7926f26 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java @@ -8,11 +8,14 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.github.hhhzzzsss.songplayer.CommandProcessor; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.text.Text; + +import javax.annotation.Nullable; @Mixin(ClientPlayerEntity.class) public class ClientPlayerEntityMixin { - @Inject(at = @At("HEAD"), method = "sendChatMessage(Ljava/lang/String;)V", cancellable=true) - private void onSendChatMessage(String message, CallbackInfo ci) { + @Inject(at = @At("HEAD"), method = "sendChatMessage(Ljava/lang/String;Lnet/minecraft/text/Text;)V", cancellable=true) + private void onSendChatMessage(String message, @Nullable Text preview, CallbackInfo ci) { boolean isCommand = CommandProcessor.processChatMessage(message); if (isCommand) { ci.cancel(); diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java index fbbc850..38898d7 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/BuildingThread.java @@ -75,7 +75,7 @@ public class BuildingThread extends Thread { } } - player.sendChatMessage(SongPlayer.creativeCommand); + player.sendCommand(SongPlayer.creativeCommand); try { //delay in case of block updates Thread.sleep(1000); } catch (InterruptedException e) { @@ -189,6 +189,6 @@ public class BuildingThread extends Thread { fx += p.getX(); fy += p.getY(); fz += p.getZ(); - SongPlayer.MC.interactionManager.interactBlock(player, world, Hand.MAIN_HAND, new BlockHitResult(new Vec3d(fx, fy, fz), Direction.UP, p, false)); + SongPlayer.MC.interactionManager.interactBlock(player, Hand.MAIN_HAND, new BlockHitResult(new Vec3d(fx, fy, fz), Direction.UP, p, false)); } } diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java index e9fb5e4..7dfecfa 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/noteblocks/PlayingThread.java @@ -14,7 +14,7 @@ public class PlayingThread extends Thread{ private final Song song = SongPlayer.song; public void run() { - player.sendChatMessage(SongPlayer.survivalCommand); + player.sendCommand(SongPlayer.survivalCommand); while (SongPlayer.MC.interactionManager.getCurrentGameMode() != GameMode.SURVIVAL) { if (SongPlayer.mode != SongPlayer.Mode.PLAYING) {return;} try { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 69a0db9..aa466f4 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,9 +26,10 @@ ], "depends": { - "fabricloader": ">=0.13.3", + "fabricloader": ">=0.14.6", "fabric": "*", - "minecraft": "1.18.x" + "minecraft": "~1.19", + "java": ">=17" }, "suggests": { "flamingo": "*"