diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/Extras.java b/src/main/java/land/chipmunk/kaboomfabric/extras/Extras.java index afa2d66..8dc78f0 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/Extras.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/Extras.java @@ -1,14 +1,14 @@ package land.chipmunk.kaboomfabric.extras; import net.fabricmc.api.ModInitializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import net.minecraft.util.Formatting; import com.mojang.brigadier.CommandDispatcher; import land.chipmunk.kaboomfabric.extras.commands.*; public class Extras implements ModInitializer { - public static final Logger LOGGER = LoggerFactory.getLogger("extras"); + public static final Logger LOGGER = LogManager.getLogger("infinite-fixes"); private static final char[] escapeCodes = "0123456789abcdefklmnorx".toCharArray(); @Override diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java index eb1c5c8..677c24b 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandClearChat.java @@ -7,7 +7,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode; import static net.minecraft.server.command.CommandManager.literal; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; -import net.minecraft.text.MutableText; +import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; import net.minecraft.server.network.ServerPlayerEntity; @@ -23,9 +23,9 @@ public interface CommandClearChat { } static int clearChatCommand (CommandContext context) { - final MutableText text = Text.literal(""); - for (int i = 0; i < 100; i++) text.append(Text.literal("\n")); - text.append(Text.literal("The chat has been cleared").formatted(Formatting.DARK_GREEN)); + final Text text = new LiteralText(""); + for (int i = 0; i < 100; i++) text.append(new LiteralText("\n")); + text.append(new LiteralText("The chat has been cleared").formatted(Formatting.DARK_GREEN)); for (ServerPlayerEntity player : context.getSource().getServer().getPlayerManager().getPlayerList()) { player.sendMessage(text); diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java index 69a1dfd..96bd7ee 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandDestroyEntities.java @@ -11,7 +11,7 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.MinecraftServer; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; // Currently broken public interface CommandDestroyEntities { @@ -44,11 +44,11 @@ public interface CommandDestroyEntities { } source.sendFeedback( - Text.literal("Successfully destroyed ") - .append(Text.literal(String.valueOf(entityCount))) - .append(Text.literal(" entities in ")) - .append(Text.literal(String.valueOf(worldCount))) - .append(Text.literal(" worlds")), + new LiteralText("Successfully destroyed ") + .append(new LiteralText(String.valueOf(entityCount))) + .append(new LiteralText(" entities in ")) + .append(new LiteralText(String.valueOf(worldCount))) + .append(new LiteralText(" worlds")), true); return Command.SINGLE_SUCCESS; diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandEnchantAll.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandEnchantAll.java index 172355d..4c16107 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandEnchantAll.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandEnchantAll.java @@ -7,19 +7,19 @@ import static net.minecraft.server.command.CommandManager.literal; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; import net.minecraft.util.Identifier; -import net.minecraft.registry.Registries; -import net.minecraft.nbt.NbtList; -import net.minecraft.nbt.NbtCompound; -import net.minecraft.nbt.NbtElement; +import net.minecraft.item.Items; +import net.minecraft.nbt.ListTag; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; public abstract class CommandEnchantAll { - private static final SimpleCommandExceptionType EMPTY_ITEM_EXCEPTION = new SimpleCommandExceptionType(Text.literal("Please hold an item in your hand to enchant it")); + private static final SimpleCommandExceptionType EMPTY_ITEM_EXCEPTION = new SimpleCommandExceptionType(new LiteralText("Please hold an item in your hand to enchant it")); public static void register (CommandDispatcher dispatcher) { dispatcher.register( @@ -34,9 +34,9 @@ public abstract class CommandEnchantAll { final ServerPlayerEntity player = source.getPlayerOrThrow(); final PlayerInventory inventory = player.getInventory(); - final NbtList enchantments = new NbtList(); - for (Identifier identifier : Registries.ENCHANTMENT.getIds()) { - final NbtCompound enchantment = new NbtCompound(); + final ListTag enchantments = new ListTag(); + for (Identifier identifier : Registry.ENCHANTMENT.getIds()) { + final CompoundTag enchantment = new CompoundTag(); enchantment.putString("id", identifier.toString()); enchantment.putShort("lvl", (short) 0xFF); enchantments.add(enchantment); @@ -45,15 +45,15 @@ public abstract class CommandEnchantAll { final ItemStack stack = inventory.getStack(inventory.selectedSlot).copy(); if (stack.isEmpty()) throw EMPTY_ITEM_EXCEPTION.create(); - NbtCompound nbt = stack.getNbt(); + CompoundTag nbt = stack.getNbt(); if (nbt == null) { - nbt = new NbtCompound(); + nbt = new CompoundTag(); stack.setNbt(nbt); } stack.getNbt().put("Enchantments", enchantments); inventory.setStack(inventory.selectedSlot, stack); - source.sendFeedback(Text.literal("I killed Martin."), false); + source.sendFeedback(new LiteralText("I killed Martin."), false); return Command.SINGLE_SUCCESS; } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java index 2cb892e..171956b 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandJumpscare.java @@ -7,18 +7,18 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.tree.LiteralCommandNode; import static net.minecraft.server.command.CommandManager.literal; import static net.minecraft.server.command.CommandManager.argument; -import static net.minecraft.command.argument.EntityArgumentType.players; -import static net.minecraft.command.argument.EntityArgumentType.getPlayers; +import static net.minecraft.command.arguments.EntityArgumentType.players; +import static net.minecraft.command.arguments.EntityArgumentType.getPlayers; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.registry.Registries; +import net.minecraft.item.Items; import net.minecraft.util.Identifier; import net.minecraft.particle.ParticleEffect; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.Vec3d; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; import java.util.Collection; public interface CommandJumpscare { @@ -38,8 +38,8 @@ public interface CommandJumpscare { static int jumpscareCommand (CommandContext context) throws CommandSyntaxException { final ServerCommandSource source = context.getSource(); final Collection players = getPlayers(context, "targets"); - final ParticleEffect particle = (ParticleEffect) Registries.PARTICLE_TYPE.get(new Identifier("minecraft", "elder_guardian")); - final SoundEvent soundEvent = Registries.SOUND_EVENT.get(new Identifier("minecraft", "entity.enderman.scream")); + final ParticleEffect particle = (ParticleEffect) Registry.PARTICLE_TYPE.get(new Identifier("minecraft", "elder_guardian")); + final SoundEvent soundEvent = Registry.SOUND_EVENT.get(new Identifier("minecraft", "entity.enderman.scream")); for (ServerPlayerEntity player : players) { final ServerWorld world = player.getWorld(); @@ -53,15 +53,15 @@ public interface CommandJumpscare { final ServerPlayerEntity player = (ServerPlayerEntity) players.toArray()[0]; source.sendFeedback( - Text.literal("Successfully created jumpscare for player \"") - .append(Text.literal(player.getGameProfile().getName())) - .append(Text.literal("\"")) + new LiteralText("Successfully created jumpscare for player \"") + .append(new LiteralText(player.getGameProfile().getName())) + .append(new LiteralText("\"")) , true); return Command.SINGLE_SUCCESS; } - source.sendFeedback(Text.literal("Successfully created jumpscare for multiple players"), true); + source.sendFeedback(new LiteralText("Successfully created jumpscare for multiple players"), true); return Command.SINGLE_SUCCESS; } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandKaboom.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandKaboom.java index fb7068c..7c74908 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandKaboom.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandKaboom.java @@ -10,7 +10,7 @@ import net.minecraft.world.World; import net.minecraft.server.world.ServerWorld; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.registry.Registries; +import net.minecraft.item.Items; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; import net.minecraft.block.BlockState; @@ -40,9 +40,8 @@ public interface CommandKaboom { world.createExplosion(player, position.getX(), position.getY(), position.getZ(), power, true, World.ExplosionSourceType.MOB); - final int power2 = 4; - final BlockState lava = Registries.BLOCK.get(new Identifier("minecraft", "lava")).getDefaultState(); + final BlockState lava = Registry.BLOCK.get(new Identifier("minecraft", "lava")).getDefaultState(); for (int i = 0; i < explosionCount; i++) { final double posX = position.getX() + ThreadLocalRandom.current().nextInt(-15, 15); @@ -57,13 +56,13 @@ public interface CommandKaboom { world.setBlockState(blockPos, lava); } - player.sendMessage(Text.literal("Forgive me :c")); + player.sendMessage(new LiteralText("Forgive me :c")); return Command.SINGLE_SUCCESS; } final PlayerInventory inventory = player.getInventory(); - inventory.setStack(inventory.selectedSlot, new ItemStack(Registries.ITEM.get(new Identifier("minecraft", "cake")))); - player.sendMessage(Text.literal("Have a nice day :)")); + inventory.setStack(inventory.selectedSlot, new ItemStack(Items.get(new Identifier("minecraft", "cake")))); + player.sendMessage(new LiteralText("Have a nice day :)")); return Command.SINGLE_SUCCESS; } } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java index ca81c51..9aa4e7e 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPing.java @@ -7,10 +7,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.tree.LiteralCommandNode; import static net.minecraft.server.command.CommandManager.literal; import static net.minecraft.server.command.CommandManager.argument; -import static net.minecraft.command.argument.EntityArgumentType.player; -import static net.minecraft.command.argument.EntityArgumentType.getPlayer; +import static net.minecraft.command.arguments.EntityArgumentType.player; +import static net.minecraft.command.arguments.EntityArgumentType.getPlayer; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; import net.minecraft.server.network.ServerPlayerEntity; @@ -37,10 +37,10 @@ public abstract class CommandPing { final Formatting highlighting = getHighlighting(ping); source.sendFeedback( - Text.literal("Your") - .append(Text.literal(" ping is ")) - .append(Text.literal(String.valueOf(ping)).formatted(highlighting)) - .append(Text.literal("ms.").formatted(highlighting)) + new LiteralText("Your") + .append(new LiteralText(" ping is ")) + .append(new LiteralText(String.valueOf(ping)).formatted(highlighting)) + .append(new LiteralText("ms.").formatted(highlighting)) , false); return Command.SINGLE_SUCCESS; @@ -53,11 +53,11 @@ public abstract class CommandPing { final Formatting highlighting = getHighlighting(ping); source.sendFeedback( - Text.literal(target.getGameProfile().getName()) - .append(Text.literal("'s")) - .append(Text.literal(" ping is ")) - .append(Text.literal(String.valueOf(ping)).formatted(highlighting)) - .append(Text.literal("ms.").formatted(highlighting)) + new LiteralText(target.getGameProfile().getName()) + .append(new LiteralText("'s")) + .append(new LiteralText(" ping is ")) + .append(new LiteralText(String.valueOf(ping)).formatted(highlighting)) + .append(new LiteralText("ms.").formatted(highlighting)) , false); return Command.SINGLE_SUCCESS; diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java index 04721eb..fb31ee3 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandPumpkin.java @@ -6,16 +6,16 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import static net.minecraft.server.command.CommandManager.literal; import static net.minecraft.server.command.CommandManager.argument; -import static net.minecraft.command.argument.EntityArgumentType.players; -import static net.minecraft.command.argument.EntityArgumentType.getPlayers; +import static net.minecraft.command.arguments.EntityArgumentType.players; +import static net.minecraft.command.arguments.EntityArgumentType.getPlayers; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.registry.Registries; +import net.minecraft.item.Items; import net.minecraft.util.Identifier; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; import java.util.Collection; // Not currently working because I don't understand the player inventory numbers @@ -34,7 +34,7 @@ public interface CommandPumpkin { static int pumpkinCommand (CommandContext context) throws CommandSyntaxException { final ServerCommandSource source = context.getSource(); final Collection players = getPlayers(context, "targets"); - final Item pumpkin = Registries.ITEM.get(new Identifier("minecraft", "pumpkin")); + final Item pumpkin = Items.get(new Identifier("minecraft", "pumpkin")); for (ServerPlayerEntity player : players) { final PlayerInventory inventory = player.getInventory(); @@ -45,15 +45,15 @@ public interface CommandPumpkin { final ServerPlayerEntity player = (ServerPlayerEntity) players.toArray()[0]; source.sendFeedback( - Text.literal("Player \"") - .append(Text.literal(player.getGameProfile().getName())) - .append(Text.literal("\" is now a pumpkin")) + new LiteralText("Player \"") + .append(new LiteralText(player.getGameProfile().getName())) + .append(new LiteralText("\" is now a pumpkin")) , true); return Command.SINGLE_SUCCESS; } - source.sendFeedback(Text.literal("Multiple players are now pumpkins"), true); + source.sendFeedback(new LiteralText("Multiple players are now pumpkins"), true); return Command.SINGLE_SUCCESS; } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java index 9121d3c..6426100 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandServerInfo.java @@ -5,8 +5,7 @@ import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.context.CommandContext; import static net.minecraft.server.command.CommandManager.literal; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.text.Text; -import net.minecraft.text.MutableText; +import net.minecraft.text.LiteralText; import net.minecraft.util.Formatting; import java.io.BufferedReader; import java.io.InputStreamReader; @@ -24,8 +23,8 @@ public abstract class CommandServerInfo { private static void sendInfoMessage (ServerCommandSource source, String description, String value) { source.sendFeedback( - Text.literal(description).formatted(Formatting.GRAY) - .append(Text.literal(": " + value).formatted(Formatting.WHITE)) + new LiteralText(description).formatted(Formatting.GRAY) + .append(new LiteralText(": " + value).formatted(Formatting.WHITE)) , false); } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpawn.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpawn.java index 8af7830..74c4b8b 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpawn.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpawn.java @@ -10,8 +10,7 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.world.ServerWorld; import net.minecraft.entity.Entity; import net.minecraft.util.math.Vec3d; -import net.minecraft.network.packet.s2c.play.PositionFlag; -import net.minecraft.text.Text; +import net.minecraft.text.LiteralText; import java.util.Set; import java.util.HashSet; @@ -32,10 +31,9 @@ public interface CommandSpawn { final Vec3d spawn = Vec3d.ofCenter(world.getSpawnPos()); final float spawnAngle = world.getSpawnAngle(); - final Set positionFlags = new HashSet<>(); entity.teleport(world, spawn.getX(), spawn.getY(), spawn.getZ(), positionFlags, spawnAngle, 0); - source.sendFeedback(Text.literal("Successfully moved to spawn"), false); + source.sendFeedback(new LiteralText("Successfully moved to spawn"), false); return Command.SINGLE_SUCCESS; } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpidey.java b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpidey.java index 70e5910..a9e7667 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpidey.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/commands/CommandSpidey.java @@ -9,7 +9,7 @@ import static net.minecraft.server.command.CommandManager.argument; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.entity.Entity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.registry.Registries; +import net.minecraft.item.Items; import net.minecraft.util.Identifier; import net.minecraft.block.BlockState; import net.minecraft.util.math.Vec3d; @@ -37,7 +37,7 @@ public abstract class CommandSpidey { final BlockIterator iterator = new BlockIterator(start, direction, yOffset, distance); - final BlockState cobweb = Registries.BLOCK.get(new Identifier("minecraft", "cobweb")).getDefaultState(); + final BlockState cobweb = Registry.BLOCK.get(new Identifier("minecraft", "cobweb")).getDefaultState(); while (iterator.hasNext()) { BlockPos pos = iterator.next(); diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/CommandManagerMixin.java b/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/CommandManagerMixin.java index 8826db9..c837736 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/CommandManagerMixin.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/CommandManagerMixin.java @@ -8,7 +8,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.command.CommandRegistryAccess; import com.mojang.brigadier.CommandDispatcher; @Mixin(CommandManager.class) @@ -17,7 +16,7 @@ public abstract class CommandManagerMixin { private CommandDispatcher dispatcher; @Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/CommandDispatcher;setConsumer(Lcom/mojang/brigadier/ResultConsumer;)V", remap = false), method = "") - private void init (CommandManager.RegistrationEnvironment environment, CommandRegistryAccess commandRegistryAccess, CallbackInfo info) { + private void init (boolean isDedicatedServer, CallbackInfo info) { Extras.registerCommands(dispatcher); } } diff --git a/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/ReloadCommandMixin.java b/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/ReloadCommandMixin.java index fc7bcf7..b311410 100644 --- a/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/ReloadCommandMixin.java +++ b/src/main/java/land/chipmunk/kaboomfabric/extras/mixin/ReloadCommandMixin.java @@ -9,8 +9,8 @@ import java.util.Collection; @Mixin(net.minecraft.server.command.ReloadCommand.class) public abstract class ReloadCommandMixin { - @Inject(at = @At("HEAD"), method = "tryReloadDataPacks", cancellable = true) - private static void tryReloadDataPacks (Collection datapacks, ServerCommandSource source, CallbackInfo info) { + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;reload()V"), method = "method_13530", cancellable = true) + private static void reload (Collection datapacks, ServerCommandSource source, CallbackInfo info) { info.cancel(); } }