From de8df562de92a58bdfb318f331ef56f028049af4 Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Sat, 11 Jun 2022 20:58:16 -0700 Subject: [PATCH] Bump to 1.19 --- gradle.properties | 8 ++++---- .../party/_2a03/mc/MinecraftTweaks2a03.java | 18 ++++++++++-------- .../party/_2a03/mc/command/ConfigCommand.java | 6 +++--- .../party/_2a03/mc/command/FlyCommand.java | 8 ++++---- .../party/_2a03/mc/command/HatCommand.java | 4 ++-- .../party/_2a03/mc/command/HeadCommand.java | 4 ++-- .../party/_2a03/mc/command/HomeCommand.java | 10 +++++----- .../party/_2a03/mc/command/SpawnCommand.java | 10 +++++----- .../_2a03/mc/mixin/MixinGameModeCommand.java | 4 ++-- .../mc/mixin/MixinServerPlayerEntity.java | 2 +- src/main/resources/fabric.mod.json | 4 ++-- 11 files changed, 40 insertions(+), 38 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6efe6bc..e1f7a62 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs=-Xmx1G -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.2 +loader_version=0.14.7 mod_version=1.2.0 maven_group=party._2a03.mc archives_base_name=minecraft-tweaks-2a03 -fabric_version=0.47.10+1.18.2 +fabric_version=0.55.3+1.19 diff --git a/src/main/java/party/_2a03/mc/MinecraftTweaks2a03.java b/src/main/java/party/_2a03/mc/MinecraftTweaks2a03.java index d6666a0..55872b3 100644 --- a/src/main/java/party/_2a03/mc/MinecraftTweaks2a03.java +++ b/src/main/java/party/_2a03/mc/MinecraftTweaks2a03.java @@ -1,8 +1,8 @@ package party._2a03.mc; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; -import net.fabricmc.fabric.api.registry.CommandRegistry; import net.fabricmc.loader.api.FabricLoader; import java.io.File; import java.nio.file.Files; @@ -49,13 +49,15 @@ public class MinecraftTweaks2a03 implements ModInitializer { Database.close(); }); LOGGER.info("Registering 2a03.party commands"); - CommandRegistry.INSTANCE.register(false, dispatcher -> { - ConfigCommand.register(dispatcher); - FlyCommand.register(dispatcher); - HatCommand.register(dispatcher); - HeadCommand.register(dispatcher); - HomeCommand.register(dispatcher); - SpawnCommand.register(dispatcher); + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { + if (environment.dedicated) { + ConfigCommand.register(dispatcher); + FlyCommand.register(dispatcher); + HatCommand.register(dispatcher); + HeadCommand.register(dispatcher); + HomeCommand.register(dispatcher); + SpawnCommand.register(dispatcher); + } }); } } diff --git a/src/main/java/party/_2a03/mc/command/ConfigCommand.java b/src/main/java/party/_2a03/mc/command/ConfigCommand.java index 1f7545c..200248c 100644 --- a/src/main/java/party/_2a03/mc/command/ConfigCommand.java +++ b/src/main/java/party/_2a03/mc/command/ConfigCommand.java @@ -4,7 +4,7 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import party._2a03.mc.util.Config; public class ConfigCommand { @@ -17,9 +17,9 @@ public class ConfigCommand { ServerCommandSource source = ctx.getSource(); try { Config.loadConfig(); - source.sendFeedback(new LiteralText("Reloaded the configuration"), true); + source.sendFeedback(Text.of("Reloaded the configuration"), true); } catch(Exception e) { - source.sendFeedback(new LiteralText("Failed to reload the configuration"), true); + source.sendFeedback(Text.of("Failed to reload the configuration"), true); } return 1; })); diff --git a/src/main/java/party/_2a03/mc/command/FlyCommand.java b/src/main/java/party/_2a03/mc/command/FlyCommand.java index 6aca014..def8ea5 100644 --- a/src/main/java/party/_2a03/mc/command/FlyCommand.java +++ b/src/main/java/party/_2a03/mc/command/FlyCommand.java @@ -5,7 +5,7 @@ import net.minecraft.entity.player.PlayerAbilities; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import party._2a03.mc.util.Config; public class FlyCommand { @@ -13,7 +13,7 @@ public class FlyCommand { dispatcher.register(CommandManager.literal("fly").executes(ctx -> { ServerCommandSource source = ctx.getSource(); if (Config.getBool("disableFlyCommand")) { - source.sendFeedback(new LiteralText("The /fly command is disabled"), true); + source.sendFeedback(Text.of("The /fly command is disabled"), true); return 0; } ServerPlayerEntity sender = source.getPlayer(); @@ -21,9 +21,9 @@ public class FlyCommand { boolean flight = abilities.allowFlying; abilities.allowFlying = !flight; if (!flight) - source.sendFeedback(new LiteralText("I wanna fly like an eagle... to the sea!"), true); + source.sendFeedback(Text.of("I wanna fly like an eagle... to the sea!"), true); else { - source.sendFeedback(new LiteralText("Flight disabled"), true); + source.sendFeedback(Text.of("Flight disabled"), true); abilities.flying = false; } sender.sendAbilitiesUpdate(); diff --git a/src/main/java/party/_2a03/mc/command/HatCommand.java b/src/main/java/party/_2a03/mc/command/HatCommand.java index f6eaede..c3ff6ac 100644 --- a/src/main/java/party/_2a03/mc/command/HatCommand.java +++ b/src/main/java/party/_2a03/mc/command/HatCommand.java @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; public class HatCommand { public static void register(CommandDispatcher dispatcher) { @@ -17,7 +17,7 @@ public class HatCommand { ItemStack head = sender.getEquippedStack(EquipmentSlot.HEAD); sender.equipStack(EquipmentSlot.MAINHAND, head); sender.equipStack(EquipmentSlot.HEAD, mainhand); - source.sendFeedback(new LiteralText("Swapped items between main hand and head"), false); + source.sendFeedback(Text.of("Swapped items between main hand and head"), false); return 1; })); } diff --git a/src/main/java/party/_2a03/mc/command/HeadCommand.java b/src/main/java/party/_2a03/mc/command/HeadCommand.java index b156d6c..3447e0a 100644 --- a/src/main/java/party/_2a03/mc/command/HeadCommand.java +++ b/src/main/java/party/_2a03/mc/command/HeadCommand.java @@ -10,7 +10,7 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; public class HeadCommand { public static void register(CommandDispatcher dispatcher) { @@ -29,7 +29,7 @@ public class HeadCommand { ItemEntity itementity = sender.dropItem(itemstack, false); itementity.resetPickupDelay(); itementity.setOwner(sender.getUuid()); - source.sendFeedback(new LiteralText("Player head has been given"), false); + source.sendFeedback(Text.of("Player head has been given"), false); return 1; } } diff --git a/src/main/java/party/_2a03/mc/command/HomeCommand.java b/src/main/java/party/_2a03/mc/command/HomeCommand.java index 3a84def..cc1d3dd 100644 --- a/src/main/java/party/_2a03/mc/command/HomeCommand.java +++ b/src/main/java/party/_2a03/mc/command/HomeCommand.java @@ -6,7 +6,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.util.registry.RegistryKey; import party._2a03.mc.util.Database; import party._2a03.mc.util.PlayerData; @@ -19,11 +19,11 @@ public class HomeCommand { ServerPlayerEntity sender = source.getPlayer(); PlayerPosition position = Database.getPlayer(sender.getUuid().toString()).getHome(); if (position.registrykey == null) { - source.sendFeedback(new LiteralText("Home not found, do /home set"), false); + source.sendFeedback(Text.of("Home not found, do /home set"), false); return -1; } sender.teleport(sender.getServer().getWorld(position.registrykey), position.x, position.y, position.z, position.yaw, position.pitch); - source.sendFeedback(new LiteralText("Teleported to home"), true); + source.sendFeedback(Text.of("Teleported to home"), true); return 1; }); @@ -39,7 +39,7 @@ public class HomeCommand { RegistryKey registrykey = sender.getWorld().getRegistryKey(); PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey); playerdata.setHome(location); - source.sendFeedback(new LiteralText("Your home has been updated"), true); + source.sendFeedback(Text.of("Your home has been updated"), true); return 1; })); @@ -57,7 +57,7 @@ public class HomeCommand { RegistryKey registrykey = sender.getWorld().getRegistryKey(); PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey); playerdata.setHome(location); - source.sendFeedback(new LiteralText("User's home has been updated (" + StringArgumentType.getString(ctx, "UUID") + ")"), true); + source.sendFeedback(Text.of("User's home has been updated (" + StringArgumentType.getString(ctx, "UUID") + ")"), true); return 1; }))); diff --git a/src/main/java/party/_2a03/mc/command/SpawnCommand.java b/src/main/java/party/_2a03/mc/command/SpawnCommand.java index 4d845f3..e1a8536 100644 --- a/src/main/java/party/_2a03/mc/command/SpawnCommand.java +++ b/src/main/java/party/_2a03/mc/command/SpawnCommand.java @@ -5,7 +5,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.util.registry.RegistryKey; import party._2a03.mc.util.Config; import party._2a03.mc.util.PlayerPosition; @@ -18,14 +18,14 @@ public class SpawnCommand { PlayerPosition position = new PlayerPosition(Config.getData("spawn")); if (position.registrykey == null) { if (source.hasPermissionLevel(2)) { - source.sendFeedback(new LiteralText("Spawn not found, do /spawn set"), false); + source.sendFeedback(Text.of("Spawn not found, do /spawn set"), false); } else { - source.sendFeedback(new LiteralText("Spawn not found, ask an admin to set it"), false); + source.sendFeedback(Text.of("Spawn not found, ask an admin to set it"), false); } return -1; } sender.teleport(sender.getServer().getWorld(position.registrykey), position.x, position.y, position.z, position.yaw, position.pitch); - source.sendFeedback(new LiteralText("Teleported to the spawn point"), true); + source.sendFeedback(Text.of("Teleported to the spawn point"), true); return 1; }); @@ -42,7 +42,7 @@ public class SpawnCommand { RegistryKey registrykey = sender.getWorld().getRegistryKey(); PlayerPosition location = new PlayerPosition(x, y, z, yaw, pitch, registrykey); Config.setData("spawn", location.getJSON()); - source.sendFeedback(new LiteralText("Spawn has been set"), true); + source.sendFeedback(Text.of("Spawn has been set"), true); return 1; })); diff --git a/src/main/java/party/_2a03/mc/mixin/MixinGameModeCommand.java b/src/main/java/party/_2a03/mc/mixin/MixinGameModeCommand.java index 6b51fcd..e59a55c 100644 --- a/src/main/java/party/_2a03/mc/mixin/MixinGameModeCommand.java +++ b/src/main/java/party/_2a03/mc/mixin/MixinGameModeCommand.java @@ -5,7 +5,7 @@ import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.GameModeCommand; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.world.GameMode; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -17,7 +17,7 @@ public class MixinGameModeCommand { @Inject(method = "execute", at = @At("HEAD")) private static void OnExecute(CommandContext context, Collection targets, GameMode gameMode, CallbackInfoReturnable cir) { if (gameMode == GameMode.CREATIVE) { - context.getSource().sendFeedback(new LiteralText(" Creative mode? What are you, a cheater?"), false); + context.getSource().sendFeedback(Text.of(" Creative mode? What are you, a cheater?"), false); } return; } diff --git a/src/main/java/party/_2a03/mc/mixin/MixinServerPlayerEntity.java b/src/main/java/party/_2a03/mc/mixin/MixinServerPlayerEntity.java index 78e2af9..39acc6b 100644 --- a/src/main/java/party/_2a03/mc/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/party/_2a03/mc/mixin/MixinServerPlayerEntity.java @@ -18,7 +18,7 @@ public abstract class MixinServerPlayerEntity extends PlayerEntity { private RegistryKey spawnPointDimension; public MixinServerPlayerEntity() { - super(null, null, 0, null); + super(null, null, 0, null, null); } @Inject(method = "moveToSpawn", at = @At("HEAD"), cancellable = true) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c077361..970e9a8 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -23,8 +23,8 @@ "minecraft-tweaks-2a03.mixins.json" ], "depends": { - "fabricloader": ">=0.12.12", + "fabricloader": ">=0.14.7", "fabric": "*", - "minecraft": "1.18.2" + "minecraft": "1.19" } }