fix the first bunch of errors

This commit is contained in:
chipmunk 2024-06-15 23:36:18 -04:00
parent ec2f02c347
commit 7449a5bb46
13 changed files with 71 additions and 76 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -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<ServerCommandSource> context) throws CommandSyntaxException {
final ServerCommandSource source = context.getSource();
final Collection<ServerPlayerEntity> 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;
}

View file

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

View file

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

View file

@ -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<ServerCommandSource> context) throws CommandSyntaxException {
final ServerCommandSource source = context.getSource();
final Collection<ServerPlayerEntity> 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;
}

View file

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

View file

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

View file

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

View file

@ -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<ServerCommandSource> dispatcher;
@Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/brigadier/CommandDispatcher;setConsumer(Lcom/mojang/brigadier/ResultConsumer;)V", remap = false), method = "<init>")
private void init (CommandManager.RegistrationEnvironment environment, CommandRegistryAccess commandRegistryAccess, CallbackInfo info) {
private void init (boolean isDedicatedServer, CallbackInfo info) {
Extras.registerCommands(dispatcher);
}
}

View file

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