diff --git a/.gitignore b/.gitignore index 79e2701..a233ec2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,40 @@ -.gradle -.idea -gradle -run -build \ No newline at end of file +# gradle + +.gradle/ +build/ +out/ +classes/ + +# eclipse + +*.launch + +# idea + +.idea/ +*.iml +*.ipr +*.iws + +# vscode + +.settings/ +.vscode/ +bin/ +.classpath +.project + +# macos + +*.DS_Store + +# fabric + +run/ + +# java + +hs_err_*.log +replay_*.log +*.hprof +*.jfr \ No newline at end of file diff --git a/build.gradle b/build.gradle index 2b7a845..14f6f46 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { - id 'fabric-loom' version '0.11-SNAPSHOT' + id 'fabric-loom' version '1.0-SNAPSHOT' + id 'maven-publish' } sourceCompatibility = JavaVersion.VERSION_17 @@ -55,3 +56,20 @@ jar { rename { "${it}_${project.archivesBaseName}"} } } + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + + // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. + repositories { + // Add repositories to publish to here. + // Notice: This block does NOT have the same function as the block in the top level. + // The repositories here will be used for publishing your artifact, not for + // retrieving dependencies. + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 8efc0bd..2c18eaf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,11 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G +org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/use - minecraft_version=1.19.2 - yarn_mappings=1.19.2+build.28 + minecraft_version=1.19.3 + yarn_mappings=1.19.3+build.5 loader_version=0.14.12 # Mod Properties @@ -14,4 +15,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.72.0+1.19.2 + fabric_version=0.71.0+1.19.3 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..943f0cb Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..f398c33 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +networkTimeout=10000 +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java b/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java index a98e8c3..e2520ce 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/FakePlayerEntity.java @@ -12,7 +12,7 @@ public class FakePlayerEntity extends OtherClientPlayerEntity { ClientWorld world = SongPlayer.MC.world; public FakePlayerEntity() { - super(SongPlayer.MC.world, SongPlayer.MC.player.getGameProfile(), SongPlayer.MC.player.getPublicKey()); + super(SongPlayer.MC.world, SongPlayer.MC.player.getGameProfile()); copyStagePosAndPlayerLook(); 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 48087cd..63abc5d 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayNetworkHandlerMixin.java @@ -1,8 +1,10 @@ package com.github.hhhzzzsss.songplayer.mixin; +import com.github.hhhzzzsss.songplayer.CommandProcessor; import com.github.hhhzzzsss.songplayer.playing.SongHandler; import com.github.hhhzzzsss.songplayer.playing.Stage; import net.minecraft.network.packet.s2c.play.PlayerRespawnS2CPacket; +import net.minecraft.text.Text; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -37,6 +39,14 @@ public class ClientPlayNetworkHandlerMixin { ci.cancel(); } } + + @Inject(at = @At("HEAD"), method = "sendChatMessage(Ljava/lang/String;)V", cancellable=true) + private void onSendChatMessage(String content, CallbackInfo ci) { + boolean isCommand = CommandProcessor.processChatMessage(content); + if (isCommand) { + ci.cancel(); + } + } @Inject(at = @At("TAIL"), method = "onGameJoin(Lnet/minecraft/network/packet/s2c/play/GameJoinS2CPacket;)V") public void onOnGameJoin(GameJoinS2CPacket packet, CallbackInfo ci) { diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java b/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java deleted file mode 100644 index 7926f26..0000000 --- a/src/main/java/com/github/hhhzzzsss/songplayer/mixin/ClientPlayerEntityMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.github.hhhzzzsss.songplayer.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -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;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(); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java b/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java index 139bfd0..39e1083 100644 --- a/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java +++ b/src/main/java/com/github/hhhzzzsss/songplayer/playing/SongHandler.java @@ -278,7 +278,7 @@ public class SongHandler { } private void checkCommandCache() { if (cachedCommand != null && System.currentTimeMillis() >= lastCommandTime + 1500) { - SongPlayer.MC.player.sendCommand(cachedCommand); + SongPlayer.MC.getNetworkHandler().sendCommand(cachedCommand); cachedCommand = null; lastCommandTime = System.currentTimeMillis(); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b56e40c..6fe0003 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,9 +26,9 @@ ], "depends": { - "fabricloader": ">=0.14.6", + "fabricloader": ">=0.14.11", "fabric": "*", - "minecraft": "~1.19", + "minecraft": "~1.19.3", "java": ">=17" }, "suggests": { diff --git a/src/main/resources/songplayer.mixins.json b/src/main/resources/songplayer.mixins.json index ca129f3..f1ff1c7 100644 --- a/src/main/resources/songplayer.mixins.json +++ b/src/main/resources/songplayer.mixins.json @@ -6,7 +6,6 @@ "mixins": [ ], "client": [ - "ClientPlayerEntityMixin", "ClientPlayNetworkHandlerMixin", "ChatInputSuggestorMixin", "InGameHudMixin",