This commit is contained in:
Harry Zhou 2022-06-10 19:11:38 -05:00
commit 2e80d56e09
9 changed files with 27 additions and 17 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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();

View file

@ -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 {

View file

@ -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);
}
}

View file

@ -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();

View file

@ -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));
}
}

View file

@ -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 {

View file

@ -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": "*"