feat: port to 1.21.7

This commit is contained in:
amyavi 2025-07-06 16:06:49 -03:00
parent 514912ba2a
commit 4ee8c7a6f3
No known key found for this signature in database
12 changed files with 36 additions and 40 deletions

View file

@ -1,5 +1,5 @@
plugins { plugins {
id 'fabric-loom' version '1.10-SNAPSHOT' id 'fabric-loom' version '1.11-SNAPSHOT'
} }
base.archivesName = project.archives_base_name base.archivesName = project.archives_base_name
@ -8,6 +8,12 @@ group = project.maven_group
repositories { repositories {
mavenCentral() mavenCentral()
// adventure snapshots
maven {
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
mavenContent { snapshotsOnly() }
}
} }
dependencies { dependencies {
@ -23,14 +29,14 @@ dependencies {
include(implementation("org.luaj:luaj-jse:3.0.1")) include(implementation("org.luaj:luaj-jse:3.0.1"))
// Configurate // Configurate
include(implementation("org.spongepowered:configurate-core:4.1.2")) include(implementation("org.spongepowered:configurate-core:4.2.0"))
include(implementation("org.spongepowered:configurate-gson:4.1.2")) include(implementation("org.spongepowered:configurate-gson:4.2.0"))
include(implementation("io.leangen.geantyref:geantyref:1.3.16")) include(implementation("io.leangen.geantyref:geantyref:1.3.16"))
// Adventure // Adventure
include(modImplementation("net.kyori:adventure-platform-fabric:6.2.0")) include(modImplementation("net.kyori:adventure-platform-fabric:6.5.0-SNAPSHOT"))
include(implementation("net.kyori:adventure-text-serializer-gson:4.18.0")) include(implementation("net.kyori:adventure-text-serializer-gson:4.23.0"))
include(implementation("net.kyori:adventure-text-serializer-legacy:4.18.0")) include(implementation("net.kyori:adventure-text-serializer-legacy:4.23.0"))
} }
processResources { processResources {

View file

@ -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.21.4 minecraft_version=1.21.7
yarn_mappings=1.21.4+build.2 yarn_mappings=1.21.7+build.6
loader_version=0.16.9 loader_version=0.16.14
# 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.113.0+1.21.4 fabric_version=0.128.2+1.21.7

View file

@ -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.12-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME

View file

@ -72,7 +72,7 @@ public class CommandManager {
} }
final MutableText text = Text.literal("") final MutableText text = Text.literal("")
.formatted(Formatting.GRAY); .formatted(Formatting.GRAY);
text.setStyle(text.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, prefix + input))); text.setStyle(text.getStyle().withClickEvent(new ClickEvent.SuggestCommand(prefix + input)));
final int cursor = Math.min(input.length(), _cursor); final int cursor = Math.min(input.length(), _cursor);

View file

@ -4,10 +4,10 @@ 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;
import land.chipmunk.chipmunkmod.modules.CommandCore; import land.chipmunk.chipmunkmod.modules.CommandCore;
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.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TextCodecs;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@ -65,8 +65,7 @@ public class CoreCommand {
final CompletableFuture<NbtCompound> future = CommandCore.INSTANCE.runTracked(command); final CompletableFuture<NbtCompound> future = CommandCore.INSTANCE.runTracked(command);
future.thenApply(tag -> { future.thenApply(tag -> {
try { try {
final String output = tag.getString("LastOutput"); tag.get("LastOutput", TextCodecs.CODEC).ifPresent(source::sendFeedback);
if (output != null) source.sendFeedback(TextUtilities.fromJson(output));
} catch (final Exception e) { } catch (final Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -43,7 +43,7 @@ public class ItemCommand {
final ItemStack stack = getItemStackArgument(context, "item").createStack(count, false); final ItemStack stack = getItemStackArgument(context, "item").createStack(count, false);
final int slot = 36 + client.player.getInventory().selectedSlot; final int slot = 36 + client.player.getInventory().getSelectedSlot();
client.getNetworkHandler().getConnection().send(new CreativeInventoryActionC2SPacket(slot, stack)); client.getNetworkHandler().getConnection().send(new CreativeInventoryActionC2SPacket(slot, stack));

View file

@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin;
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import io.netty.channel.ChannelFutureListener;
import land.chipmunk.chipmunkmod.ChipmunkMod; 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;
@ -9,7 +10,6 @@ import land.chipmunk.chipmunkmod.modules.SelfCare;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.DisconnectionInfo; import net.minecraft.network.DisconnectionInfo;
import net.minecraft.network.PacketCallbacks;
import net.minecraft.network.listener.PacketListener; import net.minecraft.network.listener.PacketListener;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket; import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
@ -17,6 +17,7 @@ import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket; import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -104,10 +105,10 @@ public class ClientConnectionMixin {
} }
} }
@WrapMethod(method = "send(Lnet/minecraft/network/packet/Packet;Lnet/minecraft/network/PacketCallbacks;Z)V") @WrapMethod(method = "send(Lnet/minecraft/network/packet/Packet;Lio/netty/channel/ChannelFutureListener;Z)V")
private void sendPacket ( private void sendPacket (
final Packet<?> packet, final Packet<?> packet,
final PacketCallbacks callbacks, final @Nullable ChannelFutureListener channelFutureListener,
final boolean flush, final boolean flush,
final Operation<Void> original final Operation<Void> original
) { ) {
@ -120,7 +121,7 @@ public class ClientConnectionMixin {
listener.packetSent(packet); listener.packetSent(packet);
} }
original.call(packet, callbacks, flush); original.call(packet, channelFutureListener, flush);
} }
@Inject(method = "disconnect(Lnet/minecraft/network/DisconnectionInfo;)V", at = @At("TAIL")) @Inject(method = "disconnect(Lnet/minecraft/network/DisconnectionInfo;)V", at = @At("TAIL"))

View file

@ -387,7 +387,7 @@ public class CommandCore implements Listener {
final int freeHotBarSlot = player.getInventory().getEmptySlot(); final int freeHotBarSlot = player.getInventory().getEmptySlot();
final int slot = 36 + freeHotBarSlot; final int slot = 36 + freeHotBarSlot;
final int oldSelectedSlot = player.getInventory().selectedSlot; final int oldSelectedSlot = player.getInventory().getSelectedSlot();
final ItemStack oldStack = player.getInventory().getStack(slot).copy(); final ItemStack oldStack = player.getInventory().getStack(slot).copy();
final ItemStack commandBlock = new ItemStack(Items.COMMAND_BLOCK); final ItemStack commandBlock = new ItemStack(Items.COMMAND_BLOCK);

View file

@ -230,7 +230,7 @@ public class SongPlayer {
final String sound = note.instrument.sound; final String sound = note.instrument.sound;
client.submit(() -> client.world.playSound( client.submit(() -> client.world.playSoundClient(
client.player.getX() + note.position.getX(), client.player.getX() + note.position.getX(),
client.player.getY() + note.position.getY(), client.player.getY() + note.position.getY(),
client.player.getZ() + note.position.getZ(), client.player.getZ() + note.position.getZ(),

View file

@ -74,10 +74,13 @@ public final class CustomChatComponentRenderer extends TranslatableComponentRend
private ClickEvent mergeClickEvent (final ClickEvent clickEvent, final CustomChatContext context) { private ClickEvent mergeClickEvent (final ClickEvent clickEvent, final CustomChatContext context) {
if (clickEvent == null) return null; if (clickEvent == null) return null;
final String value = clickEvent.value(); final ClickEvent.Payload payload = clickEvent.payload();
final String arg = context.args().get(value); if (!(payload instanceof final ClickEvent.Payload.Text text)) return clickEvent;
final String arg = context.args().get(text.value());
if (arg == null) return clickEvent; if (arg == null) return clickEvent;
// TODO: figure out solution for deprecation warning in the future
return ClickEvent.clickEvent(clickEvent.action(), arg); return ClickEvent.clickEvent(clickEvent.action(), arg);
} }
} }

View file

@ -1,21 +1,8 @@
package land.chipmunk.chipmunkmod.util; package land.chipmunk.chipmunkmod.util;
import com.google.common.base.Suppliers; import net.minecraft.text.*;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registries;
import net.minecraft.text.MutableText;
import net.minecraft.text.PlainTextContent;
import net.minecraft.text.Text;
import net.minecraft.text.TextContent;
public class TextUtilities { public class TextUtilities {
public static MutableText fromJson (final String json) {
return Text.Serialization.fromJson(
json,
Suppliers.ofInstance(DynamicRegistryManager.of(Registries.REGISTRIES)).get()
);
}
public static String plainOrNull (final Text text) { public static String plainOrNull (final Text text) {
final TextContent content = text.getContent(); final TextContent content = text.getContent();
if (!(content instanceof final PlainTextContent plainContent)) return null; if (!(content instanceof final PlainTextContent plainContent)) return null;

View file

@ -30,9 +30,9 @@
], ],
"depends": { "depends": {
"fabricloader": ">=0.16.9", "fabricloader": ">=0.16.13",
"fabric-api": "*", "fabric-api": "*",
"minecraft": "1.21.4", "minecraft": "1.21.7",
"java": ">=21" "java": ">=21"
} }
} }