Update to 1.21.1
it was such a pain to do this. for some reason core runTracked doesn't seem to work yet
This commit is contained in:
parent
42ec7a2698
commit
fef81cc15f
25 changed files with 120 additions and 132 deletions
23
build.gradle
23
build.gradle
|
@ -1,10 +1,10 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '1.0-SNAPSHOT'
|
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
sourceCompatibility = JavaVersion.VERSION_21
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = JavaVersion.VERSION_21
|
||||||
|
|
||||||
archivesBaseName = project.archives_base_name
|
archivesBaseName = project.archives_base_name
|
||||||
version = project.mod_version
|
version = project.mod_version
|
||||||
|
@ -20,6 +20,13 @@ repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/MeteorDevelopment/meteor-client/blob/master/build.gradle#L46
|
||||||
|
configurations {
|
||||||
|
implementation.extendsFrom(library)
|
||||||
|
shadow.extendsFrom(library)
|
||||||
|
include.extendsFrom(library)
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// To change the versions see the gradle.properties file
|
// To change the versions see the gradle.properties file
|
||||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||||
|
@ -29,11 +36,13 @@ dependencies {
|
||||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
modImplementation include("net.kyori:adventure-platform-fabric:5.10.0") // for Minecraft 1.20.2
|
library "net.kyori:adventure-platform-fabric:5.14.1" // for Minecraft 1.21-1.21.1
|
||||||
|
|
||||||
modImplementation include("net.kyori:adventure-text-serializer-legacy:4.13.1")
|
library "net.kyori:adventure-text-serializer-gson:4.17.0"
|
||||||
|
|
||||||
modImplementation include("org.luaj:luaj-jse:3.0.1")
|
library "net.kyori:adventure-text-serializer-legacy:4.17.0"
|
||||||
|
|
||||||
|
library "org.luaj:luaj-jse:3.0.1"
|
||||||
|
|
||||||
// Uncomment the following line to enable the deprecated Fabric API modules.
|
// Uncomment the following line to enable the deprecated Fabric API modules.
|
||||||
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
|
||||||
|
@ -51,7 +60,7 @@ processResources {
|
||||||
|
|
||||||
tasks.withType(JavaCompile).configureEach {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
||||||
it.options.release = 17
|
it.options.release = 21
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|
|
@ -4,9 +4,9 @@ org.gradle.parallel=true
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
minecraft_version=1.20.2
|
minecraft_version=1.21.1
|
||||||
yarn_mappings=1.20.2+build.1
|
yarn_mappings=1.21.1+build.3
|
||||||
loader_version=0.14.22
|
loader_version=0.16.5
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.0.0
|
mod_version = 1.0.0
|
||||||
|
@ -14,6 +14,6 @@ org.gradle.parallel=true
|
||||||
archives_base_name = chipmunkmod
|
archives_base_name = chipmunkmod
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.89.2+1.20.2
|
fabric_version=0.105.0+1.21.1
|
||||||
|
|
||||||
|
|
||||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
1
gradlew
vendored
1
gradlew
vendored
|
@ -122,6 +122,7 @@ if [ -n "$JAVA_HOME" ] ; then
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
|
JAVACMD=/usr/bin/java
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.command.CommandException;
|
|
||||||
import net.minecraft.text.ClickEvent;
|
import net.minecraft.text.ClickEvent;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.Texts;
|
import net.minecraft.text.Texts;
|
||||||
|
@ -52,8 +51,6 @@ public class CommandManager {
|
||||||
commandSource.sendError(Texts.toText(e.getRawMessage()));
|
commandSource.sendError(Texts.toText(e.getRawMessage()));
|
||||||
final Text context = getContext(e);
|
final Text context = getContext(e);
|
||||||
if (context != null) commandSource.sendError(context);
|
if (context != null) commandSource.sendError(context);
|
||||||
} catch (CommandException e) {
|
|
||||||
commandSource.sendError(e.getTextMessage());
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
commandSource.sendError(Text.of(e.getMessage()));
|
commandSource.sendError(Text.of(e.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package land.chipmunk.chipmunkmod.commands;
|
package land.chipmunk.chipmunkmod.commands;
|
||||||
|
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.context.CommandContext;
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
@ -10,6 +11,8 @@ import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||||
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
||||||
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
|
||||||
|
|
||||||
|
import land.chipmunk.chipmunkmod.util.TextUtilities;
|
||||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.nbt.NbtCompound;
|
import net.minecraft.nbt.NbtCompound;
|
||||||
|
@ -64,8 +67,9 @@ public class CoreCommand {
|
||||||
future.thenApply(tag -> {
|
future.thenApply(tag -> {
|
||||||
try {
|
try {
|
||||||
final String output = tag.getString("LastOutput");
|
final String output = tag.getString("LastOutput");
|
||||||
if (output != null) source.sendFeedback(Text.Serializer.fromJson(output));
|
if (output != null) source.sendFeedback(TextUtilities.fromJson(output));
|
||||||
} catch (Exception ignored) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return tag;
|
return tag;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||||
import land.chipmunk.chipmunkmod.modules.SongPlayer;
|
import land.chipmunk.chipmunkmod.modules.SongPlayer;
|
||||||
import land.chipmunk.chipmunkmod.song.Song;
|
import land.chipmunk.chipmunkmod.song.Song;
|
||||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.JoinConfiguration;
|
import net.kyori.adventure.text.JoinConfiguration;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
@ -219,7 +220,7 @@ public class MusicCommand {
|
||||||
mergedList.addAll(files);
|
mergedList.addAll(files);
|
||||||
final Component component = Component.translatable("Songs - %s", Component.join(JoinConfiguration.separator(Component.space()), mergedList)).color(NamedTextColor.GREEN);
|
final Component component = Component.translatable("Songs - %s", Component.join(JoinConfiguration.separator(Component.space()), mergedList)).color(NamedTextColor.GREEN);
|
||||||
|
|
||||||
MinecraftClient.getInstance().player.sendMessage(component);
|
((Audience) MinecraftClient.getInstance().player).sendMessage(component);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,8 +9,8 @@ import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
|
||||||
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
|
||||||
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.ConnectScreen;
|
|
||||||
import net.minecraft.client.gui.screen.TitleScreen;
|
import net.minecraft.client.gui.screen.TitleScreen;
|
||||||
|
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
|
||||||
import net.minecraft.client.network.ServerInfo;
|
import net.minecraft.client.network.ServerInfo;
|
||||||
import net.minecraft.client.network.ServerAddress;
|
import net.minecraft.client.network.ServerAddress;
|
||||||
import net.minecraft.client.session.Session;
|
import net.minecraft.client.session.Session;
|
||||||
|
@ -61,7 +61,7 @@ public class UsernameCommand {
|
||||||
final ServerInfo info = client.getCurrentServerEntry();
|
final ServerInfo info = client.getCurrentServerEntry();
|
||||||
client.world.disconnect();
|
client.world.disconnect();
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false);
|
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false, null);
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,13 @@ import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
||||||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
||||||
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
|
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
|
||||||
import net.minecraft.text.MutableText;
|
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -36,7 +31,7 @@ public class ChatScreenMixin extends Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true)
|
||||||
private void sendMessage (String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
|
private void sendMessage (String chatText, boolean addToHistory, CallbackInfo cir) {
|
||||||
final MinecraftClient client = MinecraftClient.getInstance();
|
final MinecraftClient client = MinecraftClient.getInstance();
|
||||||
|
|
||||||
if (addToHistory) {
|
if (addToHistory) {
|
||||||
|
@ -96,7 +91,6 @@ public class ChatScreenMixin extends Screen {
|
||||||
try {
|
try {
|
||||||
BotValidationUtilities.chomens(chatText.substring(prefixLength));
|
BotValidationUtilities.chomens(chatText.substring(prefixLength));
|
||||||
|
|
||||||
cir.setReturnValue(true);
|
|
||||||
cir.cancel();
|
cir.cancel();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -112,8 +106,6 @@ public class ChatScreenMixin extends Screen {
|
||||||
client.player.networkHandler.sendChatMessage(chatText);
|
client.player.networkHandler.sendChatMessage(chatText);
|
||||||
}
|
}
|
||||||
|
|
||||||
cir.setReturnValue(true);
|
|
||||||
|
|
||||||
cir.cancel();
|
cir.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class ClientConnectionMixin {
|
||||||
if (world == null) return;
|
if (world == null) return;
|
||||||
|
|
||||||
// huge mess
|
// huge mess
|
||||||
final SoundEvent newSound = SoundEvent.of(new Identifier(sound.getNamespace(), sound.getPath().substring(0, sound.getPath().length() - (".pitch." + stringPitch).length())));
|
final SoundEvent newSound = SoundEvent.of(Identifier.of(sound.getNamespace(), sound.getPath().substring(0, sound.getPath().length() - (".pitch." + stringPitch).length())));
|
||||||
|
|
||||||
client.executeSync(() -> world.playSound(client.player, t_packet.getX(), t_packet.getY(), t_packet.getZ(), newSound, t_packet.getCategory(), t_packet.getVolume(), pitch, t_packet.getSeed()));
|
client.executeSync(() -> world.playSound(client.player, t_packet.getX(), t_packet.getY(), t_packet.getZ(), newSound, t_packet.getCategory(), t_packet.getVolume(), pitch, t_packet.getSeed()));
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@ import land.chipmunk.chipmunkmod.command.CommandManager;
|
||||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||||
import land.chipmunk.chipmunkmod.modules.*;
|
import land.chipmunk.chipmunkmod.modules.*;
|
||||||
|
import net.kyori.adventure.platform.fabric.FabricAudiences;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.command.CommandRegistryAccess;
|
import net.minecraft.command.CommandRegistryAccess;
|
||||||
|
@ -19,6 +21,7 @@ import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
|
||||||
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
|
||||||
import net.minecraft.registry.DynamicRegistryManager;
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
import net.minecraft.resource.featuretoggle.FeatureSet;
|
import net.minecraft.resource.featuretoggle.FeatureSet;
|
||||||
|
import net.minecraft.text.PlainTextContent;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TranslatableTextContent;
|
import net.minecraft.text.TranslatableTextContent;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
@ -81,16 +84,14 @@ public class ClientPlayNetworkHandlerMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final TextComponent suggestionId = ((TextComponent) message.asComponent().children().get(0));
|
final String suggestionId = message.getSiblings().getFirst().getString();
|
||||||
final TextComponent authId = (TextComponent) message.asComponent();
|
final String authId = ((PlainTextContent) message.getContent()).string();
|
||||||
|
|
||||||
if (suggestionId.content().equals(ChomeNSBotCommandSuggestions.ID) || authId.content().equals(ChomeNSAuth.INSTANCE.id)) {
|
if (suggestionId.equals(ChomeNSBotCommandSuggestions.ID) || authId.equals(ChomeNSAuth.INSTANCE.id)) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {}
|
} catch (Exception ignored) {}
|
||||||
} catch (Exception e) {
|
} catch (Exception ignored) {}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package land.chipmunk.chipmunkmod.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.block.entity.DecoratedPotBlockEntity;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.nbt.NbtElement;
|
|
||||||
import net.minecraft.nbt.NbtList;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
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.CallbackInfoReturnable;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
||||||
|
|
||||||
// https://github.com/LunaWasFlaggedAgain/Mojang-ResourceLocation-Challenge/blob/main/src/main/java/com/github/lunawasflaggedagain/mojangresourcelocationchallenge/mixin/DecoratedPotBlockEntitySherdsMixin.java
|
|
||||||
@Mixin(DecoratedPotBlockEntity.Sherds.class)
|
|
||||||
public class DecoratedPotBlockEntitySherdsMixin {
|
|
||||||
@Inject(method = "getSherd", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;tryParse(Ljava/lang/String;)Lnet/minecraft/util/Identifier;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
|
|
||||||
private static void getSherd(NbtList list, int index, CallbackInfoReturnable<Item> cir, NbtElement nbtElement) {
|
|
||||||
if (!Identifier.isValid(nbtElement.asString())) cir.setReturnValue(Items.BRICK);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ package land.chipmunk.chipmunkmod.mixin;
|
||||||
import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
|
import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
|
||||||
import net.minecraft.client.particle.Particle;
|
import net.minecraft.client.particle.Particle;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.particle.DefaultParticleType;
|
import net.minecraft.particle.SimpleParticleType;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
@Mixin(ElderGuardianAppearanceParticle.Factory.class)
|
@Mixin(ElderGuardianAppearanceParticle.Factory.class)
|
||||||
public class ElderGuardianAppearanceParticleMixin {
|
public class ElderGuardianAppearanceParticleMixin {
|
||||||
@Inject(method = "createParticle(Lnet/minecraft/particle/DefaultParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"))
|
||||||
private void createParticle (DefaultParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
|
private void createParticle (SimpleParticleType simpleParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
|
||||||
if (cir.isCancelled() || !cir.isCancellable()) return;
|
if (cir.isCancelled() || !cir.isCancellable()) return;
|
||||||
|
|
||||||
cir.cancel();
|
cir.cancel();
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package land.chipmunk.chipmunkmod.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.SharedConstants;
|
|
||||||
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.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
@Mixin(SharedConstants.class)
|
|
||||||
public class SharedConstantsMixin {
|
|
||||||
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
|
||||||
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
|
|
||||||
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
|
|
||||||
cir.cancel();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,4 +19,10 @@ public class StringHelperMixin {
|
||||||
cir.setReturnValue(text);
|
cir.setReturnValue(text);
|
||||||
cir.cancel();
|
cir.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
|
||||||
|
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
|
||||||
|
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
|
||||||
|
cir.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,10 @@ import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import net.minecraft.text.PlainTextContent;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
import net.minecraft.text.TextContent;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -24,26 +25,26 @@ public class ChomeNSAuth extends Listener {
|
||||||
public void init () {}
|
public void init () {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void chatMessageReceived(Text message) {
|
public void chatMessageReceived(Text text) {
|
||||||
final String authKey = ChipmunkMod.CONFIG.bots.chomens.authKey;
|
final String authKey = ChipmunkMod.CONFIG.bots.chomens.authKey;
|
||||||
|
|
||||||
if (authKey == null) return;
|
if (authKey == null) return;
|
||||||
|
|
||||||
final Component component = message.asComponent();
|
final TextContent message = text.getContent();
|
||||||
|
|
||||||
if (!(component instanceof TextComponent)) return;
|
if (!(message instanceof PlainTextContent)) return;
|
||||||
|
|
||||||
final String id = ((TextComponent) component).content();
|
final String id = ((PlainTextContent) message).string();
|
||||||
|
|
||||||
if (!id.equals(this.id)) return;
|
if (!id.equals(this.id)) return;
|
||||||
|
|
||||||
final List<Component> children = component.children();
|
final List<Text> children = text.getSiblings();
|
||||||
|
|
||||||
if (children.size() != 2) return;
|
if (children.size() != 2) return;
|
||||||
|
|
||||||
if (!(children.get(0) instanceof TextComponent)) return;
|
if (!(children.getFirst().getContent() instanceof PlainTextContent)) return;
|
||||||
|
|
||||||
final String hash = ((TextComponent) children.get(0)).content();
|
final String hash = ((PlainTextContent) children.getFirst().getContent()).string();
|
||||||
|
|
||||||
final long time = System.currentTimeMillis() / 10_000;
|
final long time = System.currentTimeMillis() / 10_000;
|
||||||
|
|
||||||
|
@ -55,9 +56,9 @@ public class ChomeNSAuth extends Listener {
|
||||||
|
|
||||||
if (!hash.equals(actual)) return;
|
if (!hash.equals(actual)) return;
|
||||||
|
|
||||||
if (!(children.get(1) instanceof TextComponent)) return;
|
if (!(children.get(1).getContent() instanceof PlainTextContent)) return;
|
||||||
|
|
||||||
final String selector = ((TextComponent) children.get(1)).content();
|
final String selector = ((PlainTextContent) children.get(1).getContent()).string();
|
||||||
|
|
||||||
final String toSendHash = Hashing.sha256()
|
final String toSendHash = Hashing.sha256()
|
||||||
// very pro hash input
|
// very pro hash input
|
||||||
|
|
|
@ -6,10 +6,10 @@ import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||||
import land.chipmunk.chipmunkmod.util.UUIDUtilities;
|
import land.chipmunk.chipmunkmod.util.UUIDUtilities;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
import net.minecraft.client.network.ClientPlayerEntity;
|
||||||
|
import net.minecraft.text.PlainTextContent;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -54,31 +54,29 @@ public class ChomeNSBotCommandSuggestions extends Listener {
|
||||||
@Override
|
@Override
|
||||||
public void chatMessageReceived(Text message) {
|
public void chatMessageReceived(Text message) {
|
||||||
try {
|
try {
|
||||||
final Component component = message.asComponent();
|
final List<Text> children = message.getSiblings();
|
||||||
|
|
||||||
final List<Component> children = component.children();
|
|
||||||
|
|
||||||
if (children.isEmpty()) return;
|
if (children.isEmpty()) return;
|
||||||
|
|
||||||
final TextComponent textComponent = (TextComponent) children.get(0);
|
final Text textComponent = children.getFirst();
|
||||||
|
|
||||||
if (!textComponent.content().equals(ID)) return;
|
if (!textComponent.getString().equals(ID)) return;
|
||||||
|
|
||||||
commands = children.subList(1, children.size())
|
commands = children.subList(1, children.size())
|
||||||
.stream()
|
.stream()
|
||||||
.map(
|
.map(
|
||||||
(eachComponent) -> {
|
(eachComponent) -> {
|
||||||
final ChomeNSBotCommand command = new ChomeNSBotCommand(
|
final ChomeNSBotCommand command = new ChomeNSBotCommand(
|
||||||
ChipmunkMod.CONFIG.bots.chomens.prefix + ((TextComponent) eachComponent).content(),
|
ChipmunkMod.CONFIG.bots.chomens.prefix + ((PlainTextContent) eachComponent.getContent()).string(),
|
||||||
ChomeNSBotCommand.TrustLevel.valueOf(((TextComponent) eachComponent.children().get(0)).content())
|
ChomeNSBotCommand.TrustLevel.valueOf(eachComponent.getSiblings().getFirst().getString())
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!Boolean.parseBoolean(((TextComponent) eachComponent.children().get(1)).content())) return command;
|
if (!Boolean.parseBoolean(eachComponent.getSiblings().get(1).getString())) return command;
|
||||||
|
|
||||||
final List<Component> subList = eachComponent.children().subList(2, eachComponent.children().size());
|
final List<Text> subList = eachComponent.getSiblings().subList(2, eachComponent.getSiblings().size());
|
||||||
|
|
||||||
for (Component aliasComponent : subList) {
|
for (Text aliasComponent : subList) {
|
||||||
final String alias = ((TextComponent) aliasComponent).content();
|
final String alias = aliasComponent.getString();
|
||||||
|
|
||||||
command.aliases.add(alias);
|
command.aliases.add(alias);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
|
||||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||||
|
|
||||||
|
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
@ -146,7 +147,7 @@ public class CustomChat {
|
||||||
CommandCore.INSTANCE.run((KaboomCheck.INSTANCE.isKaboom ? "minecraft:tellraw @a " : "tellraw @a ") + sanitizedFormat);
|
CommandCore.INSTANCE.run((KaboomCheck.INSTANCE.isKaboom ? "minecraft:tellraw @a " : "tellraw @a ") + sanitizedFormat);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (client.player == null) return;
|
if (client.player == null) return;
|
||||||
client.player.sendMessage(Component.text(e.toString()).color(NamedTextColor.RED));
|
((Audience) client.player).sendMessage(Component.text(e.toString()).color(NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class KaboomCheck extends Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return packet;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class Players extends Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private MutablePlayerListEntry getEntry (PlayerListS2CPacket.Entry other) {
|
private MutablePlayerListEntry getEntry (PlayerListS2CPacket.Entry other) {
|
||||||
return getEntry(other.profile().getId());
|
return getEntry(other.profileId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayer (PlayerListS2CPacket.Entry newEntry) {
|
private void addPlayer (PlayerListS2CPacket.Entry newEntry) {
|
||||||
|
@ -137,7 +137,7 @@ public class Players extends Listener {
|
||||||
|
|
||||||
if (accessor == null) return;
|
if (accessor == null) return;
|
||||||
|
|
||||||
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profile().getId());
|
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profileId());
|
||||||
|
|
||||||
entryAccessor.setGameMode(newEntry.gameMode());
|
entryAccessor.setGameMode(newEntry.gameMode());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -155,7 +155,7 @@ public class Players extends Listener {
|
||||||
|
|
||||||
if (accessor == null) return;
|
if (accessor == null) return;
|
||||||
|
|
||||||
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profile().getId());
|
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profileId());
|
||||||
|
|
||||||
entryAccessor.setLatency(newEntry.latency());
|
entryAccessor.setLatency(newEntry.latency());
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ public class Players extends Listener {
|
||||||
|
|
||||||
if (accessor == null) return;
|
if (accessor == null) return;
|
||||||
|
|
||||||
accessor.playerListEntries().get(newEntry.profile().getId()).setDisplayName(newEntry.displayName());
|
accessor.playerListEntries().get(newEntry.profileId()).setDisplayName(newEntry.displayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removePlayer (UUID uuid) {
|
private void removePlayer (UUID uuid) {
|
||||||
|
@ -197,7 +197,7 @@ public class Players extends Listener {
|
||||||
final Message tooltip = suggestion.getTooltip();
|
final Message tooltip = suggestion.getTooltip();
|
||||||
if (tooltip != null || !suggestion.getText().equals(username)) continue;
|
if (tooltip != null || !suggestion.getText().equals(username)) continue;
|
||||||
|
|
||||||
return packet;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
list.remove(target);
|
list.remove(target);
|
||||||
|
@ -210,7 +210,7 @@ public class Players extends Listener {
|
||||||
addToPlayerList(new PlayerListEntry(entry.profile, false));
|
addToPlayerList(new PlayerListEntry(entry.profile, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
return packet;
|
return true;
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -5,6 +5,7 @@ import land.chipmunk.chipmunkmod.song.Song;
|
||||||
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
import land.chipmunk.chipmunkmod.song.SongLoaderException;
|
||||||
import land.chipmunk.chipmunkmod.song.SongLoaderThread;
|
import land.chipmunk.chipmunkmod.song.SongLoaderThread;
|
||||||
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
import land.chipmunk.chipmunkmod.util.MathUtilities;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
@ -55,34 +56,34 @@ public class SongPlayer {
|
||||||
|
|
||||||
public void loadSong (Path location) {
|
public void loadSong (Path location) {
|
||||||
if (loaderThread != null) {
|
if (loaderThread != null) {
|
||||||
client.player.sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
((Audience) client.player).sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
|
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
|
||||||
client.player.sendMessage(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
((Audience) client.player).sendMessage(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||||
_loaderThread.start();
|
_loaderThread.start();
|
||||||
loaderThread = _loaderThread;
|
loaderThread = _loaderThread;
|
||||||
} catch (SongLoaderException e) {
|
} catch (SongLoaderException e) {
|
||||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message).color(NamedTextColor.RED));
|
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED));
|
||||||
loaderThread = null;
|
loaderThread = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadSong (URL location) {
|
public void loadSong (URL location) {
|
||||||
if (loaderThread != null) {
|
if (loaderThread != null) {
|
||||||
client.player.sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
((Audience) client.player).sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
|
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
|
||||||
client.player.sendMessage(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
((Audience) client.player).sendMessage(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||||
_loaderThread.start();
|
_loaderThread.start();
|
||||||
loaderThread = _loaderThread;
|
loaderThread = _loaderThread;
|
||||||
} catch (SongLoaderException e) {
|
} catch (SongLoaderException e) {
|
||||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message).color(NamedTextColor.RED));
|
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED));
|
||||||
loaderThread = null;
|
loaderThread = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,19 +103,19 @@ public class SongPlayer {
|
||||||
|
|
||||||
if (loaderThread != null && !loaderThread.isAlive()) {
|
if (loaderThread != null && !loaderThread.isAlive()) {
|
||||||
if (loaderThread.exception != null) {
|
if (loaderThread.exception != null) {
|
||||||
client.player.sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message).color(NamedTextColor.RED));
|
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message.getString()).color(NamedTextColor.RED));
|
||||||
} else {
|
} else {
|
||||||
songQueue.add(loaderThread.song);
|
songQueue.add(loaderThread.song);
|
||||||
client.player.sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
((Audience) client.player).sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||||
}
|
}
|
||||||
loaderThread = null;
|
loaderThread = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSong == null) {
|
if (currentSong == null) {
|
||||||
if (songQueue.size() == 0) return;
|
if (songQueue.isEmpty()) return;
|
||||||
|
|
||||||
currentSong = songQueue.poll();
|
currentSong = songQueue.poll();
|
||||||
client.player.sendMessage(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
((Audience) client.player).sendMessage(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||||
currentSong.play();
|
currentSong.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +123,7 @@ public class SongPlayer {
|
||||||
else ticksUntilPausedActionbar = 20;
|
else ticksUntilPausedActionbar = 20;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!useCore && actionbar) client.player.sendActionBar(generateActionbar());
|
if (!useCore && actionbar && client.player != null) ((Audience) client.player).sendActionBar(generateActionbar());
|
||||||
else if (actionbar) CommandCore.INSTANCE.run("title " + SELECTOR + " actionbar " + GsonComponentSerializer.gson().serialize(generateActionbar()));
|
else if (actionbar) CommandCore.INSTANCE.run("title " + SELECTOR + " actionbar " + GsonComponentSerializer.gson().serialize(generateActionbar()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -133,7 +134,7 @@ public class SongPlayer {
|
||||||
handlePlaying();
|
handlePlaying();
|
||||||
|
|
||||||
if (currentSong.finished()) {
|
if (currentSong.finished()) {
|
||||||
client.player.sendMessage(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
((Audience) client.player).sendMessage(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
|
||||||
currentSong = null;
|
currentSong = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,11 +149,11 @@ public class SongPlayer {
|
||||||
final ClientPlayerEntity player = client.player;
|
final ClientPlayerEntity player = client.player;
|
||||||
|
|
||||||
Component component = Component.empty()
|
Component component = Component.empty()
|
||||||
.append(Component.translatable("%s", player.getName()).color(NamedTextColor.GREEN))
|
.append(Component.translatable("%s", player.getName().getString()).color(NamedTextColor.GREEN))
|
||||||
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
||||||
.append(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN))
|
.append(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN))
|
||||||
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
||||||
.append(Component.translatable("%s / %s", formatTime(currentSong.time).asComponent().color(NamedTextColor.GREEN), formatTime(currentSong.length).asComponent().color(NamedTextColor.GREEN)).color(NamedTextColor.GRAY))
|
.append(Component.translatable("%s / %s", formatTime(currentSong.time).color(NamedTextColor.GREEN), formatTime(currentSong.length).color(NamedTextColor.GREEN)).color(NamedTextColor.GRAY))
|
||||||
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
|
||||||
.append(Component.translatable("%s / %s", Component.text(currentSong.position, NamedTextColor.GREEN), Component.text(currentSong.size(), NamedTextColor.GREEN)).color(NamedTextColor.GRAY));
|
.append(Component.translatable("%s / %s", Component.text(currentSong.position, NamedTextColor.GREEN), Component.text(currentSong.size(), NamedTextColor.GREEN)).color(NamedTextColor.GRAY));
|
||||||
|
|
||||||
|
@ -177,16 +178,16 @@ public class SongPlayer {
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Text formatTime (long millis) {
|
public Component formatTime (long millis) {
|
||||||
final int seconds = (int) millis / 1000;
|
final int seconds = (int) millis / 1000;
|
||||||
|
|
||||||
final String minutePart = String.valueOf(seconds / 60);
|
final String minutePart = String.valueOf(seconds / 60);
|
||||||
final String unpaddedSecondPart = String.valueOf(seconds % 60);
|
final String unpaddedSecondPart = String.valueOf(seconds % 60);
|
||||||
|
|
||||||
return Text.translatable(
|
return Component.translatable(
|
||||||
"%s:%s",
|
"%s:%s",
|
||||||
Text.literal(minutePart),
|
Component.text(minutePart),
|
||||||
Text.literal(unpaddedSecondPart.length() < 2 ? "0" + unpaddedSecondPart : unpaddedSecondPart)
|
Component.text(unpaddedSecondPart.length() < 2 ? "0" + unpaddedSecondPart : unpaddedSecondPart)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TabComplete extends Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetReceived (CommandSuggestionsS2CPacket packet) {
|
public void packetReceived (CommandSuggestionsS2CPacket packet) {
|
||||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = transactions.get(packet.getCompletionId());
|
final CompletableFuture<CommandSuggestionsS2CPacket> future = transactions.get(packet.id());
|
||||||
|
|
||||||
if (future == null) return;
|
if (future == null) return;
|
||||||
future.complete(packet);
|
future.complete(packet);
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package land.chipmunk.chipmunkmod.util;
|
||||||
|
|
||||||
|
import com.google.common.base.Suppliers;
|
||||||
|
import net.minecraft.registry.DynamicRegistryManager;
|
||||||
|
import net.minecraft.registry.Registries;
|
||||||
|
import net.minecraft.text.MutableText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
public class TextUtilities {
|
||||||
|
public static MutableText fromJson (String json) {
|
||||||
|
return Text.Serialization.fromJson(
|
||||||
|
json,
|
||||||
|
Suppliers.ofInstance(DynamicRegistryManager.of(Registries.REGISTRIES)).get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
"required": true,
|
"required": true,
|
||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "land.chipmunk.chipmunkmod.mixin",
|
"package": "land.chipmunk.chipmunkmod.mixin",
|
||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_21",
|
||||||
"client": [
|
"client": [
|
||||||
"ChatInputSuggestorMixin",
|
"ChatInputSuggestorMixin",
|
||||||
"ChatScreenMixin",
|
"ChatScreenMixin",
|
||||||
|
@ -14,12 +14,10 @@
|
||||||
"StringHelperMixin",
|
"StringHelperMixin",
|
||||||
"ElderGuardianAppearanceParticleMixin",
|
"ElderGuardianAppearanceParticleMixin",
|
||||||
"IdentifierMixin",
|
"IdentifierMixin",
|
||||||
"DecoratedPotBlockEntitySherdsMixin",
|
|
||||||
"TextMixin",
|
"TextMixin",
|
||||||
"ClientConnectionInvoker",
|
"ClientConnectionInvoker",
|
||||||
"ClientConnectionAccessor",
|
"ClientConnectionAccessor",
|
||||||
"PlayerListEntryAccessor",
|
"PlayerListEntryAccessor",
|
||||||
"SharedConstantsMixin",
|
|
||||||
"TextSerializerMixin",
|
"TextSerializerMixin",
|
||||||
"CommandDispatcherMixin",
|
"CommandDispatcherMixin",
|
||||||
"SoundSystemMixin",
|
"SoundSystemMixin",
|
||||||
|
|
|
@ -30,10 +30,10 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.11",
|
"fabricloader": ">=0.16.5",
|
||||||
"fabric-api": "*",
|
"fabric-api": "*",
|
||||||
"minecraft": ">1.20",
|
"minecraft": ">=1.21",
|
||||||
"java": ">=17"
|
"java": ">=21"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"another-mod": "*"
|
"another-mod": "*"
|
||||||
|
|
Loading…
Reference in a new issue