diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandClear.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandClear.java index 7cedb1e..81389fa 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandClear.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandClear.java @@ -10,6 +10,8 @@ import net.minecraft.commands.SharedSuggestionProvider; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; @@ -56,13 +58,13 @@ private static int remove(CommandSourceStack source, int size, String filter) th var removalCheck = RemovalPredicate.getFromName(filter).orElse(RemovalPredicate.JUST_ORES); Predicate customCheck = null; if (filter.startsWith("#")) { - customCheck = state -> state.is(TagKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation(filter.replace("#", "")))); + customCheck = state -> state.is(TagKey.create(Registries.BLOCK, new ResourceLocation(filter.replace("#", "")))); } else if(filter.contains(":")) { - customCheck = state -> Registry.BLOCK.getKey(state.getBlock()).toString().equalsIgnoreCase(filter); + customCheck = state -> BuiltInRegistries.BLOCK.getKey(state.getBlock()).toString().equalsIgnoreCase(filter); } ServerLevel level = source.getLevel(); - source.sendSuccess(Component.translatable("commands.toolkit.remove.lagwarring"), true); + source.sendSuccess(() -> Component.translatable("commands.toolkit.remove.lagwarring"), true); // We're removing 1 to make it so 1 = 0, 2 - 1, etc, this means we'll have correct radius 0 = 1x1, 1 = 3x3, 2 = 5x5 var range = size - 1; @@ -98,25 +100,24 @@ private static void removeChunk(ServerLevel level, ChunkPos chunkPos, Predicate< LevelChunk chunk = level.getChunk(chunkPos.x, chunkPos.z); List sections = Arrays.stream(chunk.getSections()).filter(e -> !e.hasOnlyAir()).toList(); - for (LevelChunkSection section : sections) { - for (int y = section.bottomBlockY(); y < section.bottomBlockY() + 16; y ++) { - // For people that don't know what bit shifting is, google it... - for (int x = chunkPos.x << 4; x < (chunkPos.x << 4) + (1 << 4); x ++) { - for (int z = chunkPos.z << 4; z < (chunkPos.z << 4) + (1 << 4); z ++) { - final BlockPos pos = new BlockPos(x, y, z); - final BlockState state = level.getBlockState(pos); - // Don't remove bedrock and skip air, it's a waste of computation - if (state.isAir() || state.getBlock() == Blocks.BEDROCK) { - continue; - } + for (int y = level.getMinBuildHeight(); y < level.getMaxBuildHeight(); y ++) { + // For people that don't know what bit shifting is, google it... + for (int x = chunkPos.x << 4; x < (chunkPos.x << 4) + (1 << 4); x ++) { + for (int z = chunkPos.z << 4; z < (chunkPos.z << 4) + (1 << 4); z ++) { + final BlockPos pos = new BlockPos(x, y, z); + final BlockState state = level.getBlockState(pos); - if (blockCheck.test(state)) { - continue; - } + // Don't remove bedrock and skip air, it's a waste of computation + if (state.isAir() || state.getBlock() == Blocks.BEDROCK) { + continue; + } - level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); + if (blockCheck.test(state)) { + continue; } + + level.setBlock(pos, Blocks.AIR.defaultBlockState(), Block.UPDATE_ALL); } } } @@ -124,7 +125,7 @@ private static void removeChunk(ServerLevel level, ChunkPos chunkPos, Predicate< private enum RemovalPredicate { JUST_ORES(state -> state.is(ToolkitPlatform.getOresTag())), - ORES_AND_MODDED(state -> state.is(ToolkitPlatform.getOresTag()) && Registry.BLOCK.getKey(state.getBlock()).getNamespace().equals("minecraft")); + ORES_AND_MODDED(state -> state.is(ToolkitPlatform.getOresTag()) && BuiltInRegistries.BLOCK.getKey(state.getBlock()).getNamespace().equals("minecraft")); public static final List VALUES = Arrays.asList(values()); public static final String[] NAMES = VALUES.stream().map(e -> e.toString().toLowerCase()).toArray(String[]::new); diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandEnchant.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandEnchant.java index 16261a7..d572510 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandEnchant.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandEnchant.java @@ -5,9 +5,12 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.*; import com.sunekaer.toolkit.utils.EnchantmentHacks; +import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.commands.arguments.ItemEnchantmentArgument; +import net.minecraft.commands.arguments.ResourceArgument; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.ItemStack; @@ -21,45 +24,46 @@ public class CommandEnchant { private static final DynamicCommandExceptionType ERROR_INCOMPATIBLE = new DynamicCommandExceptionType(object -> Component.translatable("commands.enchant.failed.incompatible", object)); private static final DynamicCommandExceptionType ERROR_NO_ITEM = new DynamicCommandExceptionType(object -> Component.translatable("commands.enchant.failed.itemless", object)); - public static ArgumentBuilder register() { + public static ArgumentBuilder register(CommandBuildContext commandBuildContext) { return Commands.literal("enchant") .requires(cs -> cs.hasPermission(2)) .then(Commands.literal("add") - .then(Commands.argument("enchantment", ItemEnchantmentArgument.enchantment()) + .then(Commands.argument("enchantment", ResourceArgument.resource(commandBuildContext, Registries.ENCHANTMENT)) .then(Commands.argument("level", IntegerArgumentType.integer(0)) .executes(context -> enchant( context, - ItemEnchantmentArgument.getEnchantment(context, "enchantment"), + ResourceArgument.getEnchantment(context, "enchantment"), IntegerArgumentType.getInteger(context, "level") )) ) ) ) .then(Commands.literal("remove") - .then(Commands.argument("enchantment", ItemEnchantmentArgument.enchantment()) - .executes(context -> removeEnchantment(context, ItemEnchantmentArgument.getEnchantment(context, "enchantment")))) + .then(Commands.argument("enchantment", ResourceArgument.resource(commandBuildContext, Registries.ENCHANTMENT)) + .executes(context -> removeEnchantment(context, ResourceArgument.getEnchantment(context, "enchantment")))) ); } - private static int enchant(CommandContext context, Enchantment enchantment, int level) throws CommandSyntaxException { + private static int enchant(CommandContext context, Holder.Reference enchantment, int level) throws CommandSyntaxException { CommandSourceStack source = context.getSource(); + var enchant = enchantment.value(); var player = source.getPlayer(); var mainHandItem = getItemInHand(player); if (mainHandItem == null) { throw ERROR_MISSING_PLAYER.create(); } - if (!enchantment.canEnchant(mainHandItem) || !EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantments(mainHandItem).keySet(), enchantment)) { + if (!enchant.canEnchant(mainHandItem) || !EnchantmentHelper.isEnchantmentCompatible(EnchantmentHelper.getEnchantments(mainHandItem).keySet(), enchant)) { throw ERROR_INCOMPATIBLE.create(mainHandItem.getItem().getName(mainHandItem).getString()); } - EnchantmentHacks.enchantItem(mainHandItem, enchantment, (short) level); - source.sendSuccess(Component.translatable("commands.toolkit.enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(level).getString()), false); + EnchantmentHacks.enchantItem(mainHandItem, enchant, (short) level); + source.sendSuccess(() -> Component.translatable("commands.toolkit.enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), enchant.getFullname(level).getString()), false); return 1; } - private static int removeEnchantment(CommandContext context, Enchantment enchantment) throws CommandSyntaxException { + private static int removeEnchantment(CommandContext context, Holder.Reference enchantment) throws CommandSyntaxException { var source = context.getSource(); var player = source.getPlayer(); var mainHandItem = getItemInHand(player); @@ -67,15 +71,17 @@ private static int removeEnchantment(CommandContext context, throw ERROR_MISSING_PLAYER.create(); } - if (!EnchantmentHelper.getEnchantments(mainHandItem).containsKey(enchantment)) { - throw ERROR_MISSING_ENCHANTMENT.create(mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(1)); + var enchant = enchantment.value(); + + if (!EnchantmentHelper.getEnchantments(mainHandItem).containsKey(enchant)) { + throw ERROR_MISSING_ENCHANTMENT.create(mainHandItem.getItem().getName(mainHandItem).getString(), enchant.getFullname(1)); } - boolean success = EnchantmentHacks.removeEnchantment(mainHandItem, enchantment); + boolean success = EnchantmentHacks.removeEnchantment(mainHandItem, enchant); if (success) { - source.sendSuccess(Component.translatable("commands.toolkit.remove_enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(1).getString()), false); + source.sendSuccess(() -> Component.translatable("commands.toolkit.remove_enchant.success", mainHandItem.getItem().getName(mainHandItem).getString(), enchant.getFullname(1).getString()), false); } else { - source.sendFailure(Component.translatable("commands.toolkit.remove_enchant.failed", mainHandItem.getItem().getName(mainHandItem).getString(), enchantment.getFullname(1).getString())); + source.sendFailure(Component.translatable("commands.toolkit.remove_enchant.failed", mainHandItem.getItem().getName(mainHandItem).getString(), enchant.getFullname(1).getString())); } return success ? 1 : 0; } diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandHand.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandHand.java index 55e2cd6..5da2c87 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandHand.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandHand.java @@ -7,6 +7,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; @@ -14,6 +15,7 @@ import net.minecraft.tags.TagKey; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import java.util.ArrayList; @@ -39,8 +41,8 @@ private static int getHand(CommandSourceStack source, Player player) { return 0; } - String itemName = Objects.requireNonNull(Registry.ITEM.getKey(stack.getItem())).toString(); - List tags = new ArrayList<>(stack.getTags().collect(Collectors.toList())); + String itemName = Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(stack.getItem())).toString(); + List> tags = stack.getTags().toList(); String withNBT = ""; CompoundTag nbt = stack.save(new CompoundTag()); @@ -51,14 +53,14 @@ private static int getHand(CommandSourceStack source, Player player) { String combinedItemNBT = itemName + withNBT; - source.sendSuccess(Component.literal(combinedItemNBT).withStyle(ChatFormatting.YELLOW), true); + source.sendSuccess(() -> Component.literal(combinedItemNBT).withStyle(ChatFormatting.YELLOW), true); Handler.CHANNEL.sendToPlayer((ServerPlayer) player, new SetCopy(combinedItemNBT)); if (!tags.isEmpty()) { MutableComponent tagText = Component.literal("Tags: "); MutableComponent tagsText = Component.literal(tags.stream().map(TagKey::toString).collect(Collectors.joining(", "))); tagsText.withStyle(ChatFormatting.RED); - source.sendSuccess(tagText.append(tagsText), true); + source.sendSuccess(() -> tagText.append(tagsText), true); } return 1; diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandHotbar.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandHotbar.java index ad45aa7..9593d92 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandHotbar.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandHotbar.java @@ -7,6 +7,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; @@ -35,7 +36,7 @@ private static int getHotbar(CommandSourceStack source, Player player) { continue; } - String itemName = Objects.requireNonNull(Registry.ITEM.getKey(stack.getItem())).toString(); + String itemName = Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(stack.getItem())).toString(); String withNBT = ""; CompoundTag nbt = stack.save(new CompoundTag()); @@ -46,7 +47,7 @@ private static int getHotbar(CommandSourceStack source, Player player) { clipboard.append(itemName).append(withNBT).append(CommandUtils.NEW_LINE); } - source.sendSuccess(Component.translatable("commands.toolkit.clipboard.copied"), true); + source.sendSuccess(() -> Component.translatable("commands.toolkit.clipboard.copied"), true); Handler.CHANNEL.sendToPlayer((ServerPlayer) player, new SetCopy(clipboard.toString())); return 1; diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandInventory.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandInventory.java index b2cc919..5781661 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandInventory.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandInventory.java @@ -7,6 +7,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; @@ -35,7 +36,7 @@ private static int getHotbar(CommandSourceStack source, Player player) { continue; } - String itemName = Objects.requireNonNull(Registry.ITEM.getKey(stack.getItem())).toString(); + String itemName = Objects.requireNonNull(BuiltInRegistries.ITEM.getKey(stack.getItem())).toString(); String withNBT = ""; CompoundTag nbt = stack.save(new CompoundTag()); @@ -46,7 +47,7 @@ private static int getHotbar(CommandSourceStack source, Player player) { clipboard.append(itemName).append(withNBT).append(CommandUtils.NEW_LINE); } - source.sendSuccess(Component.translatable("commands.toolkit.clipboard.copied"), true); + source.sendSuccess(() -> Component.translatable("commands.toolkit.clipboard.copied"), true); Handler.CHANNEL.sendToPlayer((ServerPlayer) player, new SetCopy(clipboard.toString())); return 1; diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandKill.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandKill.java index 2f1b6c2..7aefa4b 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandKill.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandKill.java @@ -4,15 +4,15 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.serialization.Codec; -import dev.architectury.registry.registries.Registries; +import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.commands.arguments.EntitySummonArgument; +import net.minecraft.commands.arguments.ResourceArgument; import net.minecraft.commands.arguments.StringRepresentableArgument; import net.minecraft.commands.synchronization.SuggestionProviders; -import net.minecraft.core.Registry; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.StringRepresentable; import net.minecraft.world.entity.Entity; @@ -65,24 +65,21 @@ public static KillType getKillType(CommandContext source, St } } - public static ArgumentBuilder register() { + public static ArgumentBuilder register(CommandBuildContext commandBuildContext) { return Commands.literal("kill") .requires(cs -> cs.hasPermission(2)) .then(Commands.argument("type", KillTypeArgument.killType()) .executes(context -> kill(KillTypeArgument.getKillType(context, "type"), context.getSource()))) - .then(Commands.literal("by").then(Commands.argument("entity", EntitySummonArgument.id()).suggests(SuggestionProviders.SUMMONABLE_ENTITIES).executes(context -> killByEntity(context, EntitySummonArgument.getSummonableEntity(context, "entity"))))); + .then(Commands.literal("by").then(Commands.argument("entity", ResourceArgument.resource(commandBuildContext, Registries.ENTITY_TYPE)).suggests(SuggestionProviders.SUMMONABLE_ENTITIES).executes(context -> killByEntity(context, ResourceArgument.getSummonableEntityType(context, "entity"))))); } - private static int killByEntity(CommandContext context, ResourceLocation entityId) throws CommandSyntaxException { + private static int killByEntity(CommandContext context, Holder.Reference> entityId) throws CommandSyntaxException { CommandSourceStack source = context.getSource(); var level = source.getLevel(); - EntityType entityType = Registry.ENTITY_TYPE.get(entityId); - if (entityType == null) { - return -1; - } + EntityType entityType = entityId.value(); - source.sendSuccess(Component.translatable("commands.toolkit.kill.start", entityId), true); + source.sendSuccess(() -> Component.translatable("commands.toolkit.kill.start", entityId), true); var entitiesKilled = yeetEntities((player, entity) -> entity.getType().equals(entityType), level, source.getPlayerOrException()); yeetedEntitiesMessage(source, entitiesKilled, entityId.toString()); @@ -94,7 +91,7 @@ private static int kill(KillType type, CommandSourceStack source) throws Command int entitiesKilled = 0; String typeName = Component.translatable("commands.toolkit.kill.type." + type.name()).getString(); - source.sendSuccess(Component.translatable("commands.toolkit.kill.start", typeName), true); + source.sendSuccess(() -> Component.translatable("commands.toolkit.kill.start", typeName), true); if (type == KillType.me || type == KillType.players) { for (Player player : level.getPlayers(e -> type.checker.test(e, e))) { @@ -112,9 +109,9 @@ private static int kill(KillType type, CommandSourceStack source) throws Command private static void yeetedEntitiesMessage(CommandSourceStack source, int yeetedAmount, String typeName) { if (yeetedAmount > 0) { - source.sendSuccess(Component.translatable("commands.toolkit.kill.done", yeetedAmount), true); + source.sendSuccess(() -> Component.translatable("commands.toolkit.kill.done", yeetedAmount), true); } else { - source.sendSuccess(Component.translatable("commands.toolkit.kill.no", typeName), true); + source.sendSuccess(() -> Component.translatable("commands.toolkit.kill.no", typeName), true); } } diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandOreDist.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandOreDist.java index cf268a5..5c8334a 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandOreDist.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandOreDist.java @@ -7,6 +7,7 @@ import net.minecraft.commands.Commands; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; @@ -48,17 +49,17 @@ private static int getOreDist(CommandSourceStack source, Player player, int size double startZ = player.position().z - searchSize; double endX = player.position().x + searchSize; double endZ = player.position().z + searchSize; - Level world = player.getLevel(); + Level world = player.level(); for (int y = world.getMinBuildHeight(); y < world.getMaxBuildHeight(); ++y) { for (double x = startX; x < endX; x++) { for (double z = startZ; z < endZ; z++) { - BlockPos tBlockPos = new BlockPos(x, y, z); + BlockPos tBlockPos = BlockPos.containing(x, y, z); BlockState tBlockState = world.getBlockState(tBlockPos); Block tBlock = tBlockState.getBlock(); if (!tBlock.equals(Blocks.AIR) && !tBlock.equals(Blocks.BEDROCK) && !tBlock.equals(Blocks.STONE) && !tBlock.equals(Blocks.DIRT) && !tBlock.equals(Blocks.WATER)) { if (tBlock.builtInRegistryHolder().is(ToolkitPlatform.getOresTag())) { - ResourceLocation key1 = Registry.BLOCK.getKey(tBlock); + ResourceLocation key1 = BuiltInRegistries.BLOCK.getKey(tBlock); String key = Objects.requireNonNull(key1).toString(); Object value = map.get(key1.toString()); if (value != null) { @@ -74,11 +75,11 @@ private static int getOreDist(CommandSourceStack source, Player player, int size double sum = map.values().stream().reduce(0, Integer::sum); if (sum == 0) { - source.sendSuccess(Component.translatable("\u00A7c No ores found"), true); + source.sendSuccess(() -> Component.literal("\u00A7c No ores found"), true); return 1; } map.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).forEachOrdered(x -> - source.sendSuccess(Component.translatable("\u00A7c" + x.getKey() + " \u00A7rCount: " + x.getValue() + " (" + FORMATTER.format(x.getValue() * 100 / sum) + "%%)"), true) + source.sendSuccess(() -> Component.translatable("\u00A7c" + x.getKey() + " \u00A7rCount: " + x.getValue() + " (" + FORMATTER.format(x.getValue() * 100 / sum) + "%%)"), true) ); return 1; } diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandRepair.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandRepair.java index fd1498e..c18243d 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandRepair.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandRepair.java @@ -25,7 +25,7 @@ private static int repair(CommandContext context) throws Com } item.setDamageValue(0); - source.sendSuccess(Component.translatable("commands.toolkit.repair.success", item.getItem().getName(item).getString()), false); + source.sendSuccess(() -> Component.translatable("commands.toolkit.repair.success", item.getItem().getName(item).getString()), false); return 1; } } diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/CommandSlayer.java b/common/src/main/java/com/sunekaer/toolkit/commands/CommandSlayer.java index 540ac67..5b8434c 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/CommandSlayer.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/CommandSlayer.java @@ -43,7 +43,6 @@ private static int giveItem(ServerPlayer player) { ItemEntity drop = player.drop(itemstack.copy(), false); if (drop != null) { drop.setNoPickUpDelay(); - drop.setOwner(player.getUUID()); } } diff --git a/common/src/main/java/com/sunekaer/toolkit/commands/TKCommand.java b/common/src/main/java/com/sunekaer/toolkit/commands/TKCommand.java index 1b87351..c9f75d7 100644 --- a/common/src/main/java/com/sunekaer/toolkit/commands/TKCommand.java +++ b/common/src/main/java/com/sunekaer/toolkit/commands/TKCommand.java @@ -13,7 +13,7 @@ public static void register(CommandDispatcher dispatcher, Co .executes(c -> { ServerLevel level = c.getSource() .getPlayerOrException() - .getLevel(); + .serverLevel(); if (level.isRaining() || level.isThundering()) { level.setWeatherParameters(6000, 0, false, false); @@ -32,10 +32,10 @@ public static void register(CommandDispatcher dispatcher, Co .then(CommandHotbar.register()) .then(CommandInventory.register()) .then(CommandSlayer.register()) - .then(CommandEnchant.register()) + .then(CommandEnchant.register(context)) .then(CommandOreDist.register()) .then(CommandClear.register()) - .then(CommandKill.register()) + .then(CommandKill.register(context)) .then(CommandHeal.register()) .then(CommandRepair.register()) .then(CommandNightVision.register()) diff --git a/common/src/main/java/com/sunekaer/toolkit/event/PlayerEvents.java b/common/src/main/java/com/sunekaer/toolkit/event/PlayerEvents.java index aa2318a..368042f 100644 --- a/common/src/main/java/com/sunekaer/toolkit/event/PlayerEvents.java +++ b/common/src/main/java/com/sunekaer/toolkit/event/PlayerEvents.java @@ -8,7 +8,7 @@ public class PlayerEvents { public static void playerJoined(ServerPlayer player) { if (player != null && Toolkit.SHOW_ON_JOIN_MESSAGE.get()) { - if (!player.getLevel().isClientSide) { + if (!player.level().isClientSide) { player.displayClientMessage(Component.literal(Toolkit.JOIN_MESSAGE.get()), false); } } diff --git a/fabric/src/main/java/com/sunekaer/toolkit/fabric/DataGeneration.java b/fabric/src/main/java/com/sunekaer/toolkit/fabric/DataGeneration.java index faddcc7..fa0b320 100644 --- a/fabric/src/main/java/com/sunekaer/toolkit/fabric/DataGeneration.java +++ b/fabric/src/main/java/com/sunekaer/toolkit/fabric/DataGeneration.java @@ -2,6 +2,7 @@ import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint; import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricLanguageProvider; import java.util.stream.IntStream; @@ -9,11 +10,12 @@ public class DataGeneration implements DataGeneratorEntrypoint { @Override public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { - fabricDataGenerator.addProvider(new LanguageGenerator(fabricDataGenerator)); + FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); + pack.addProvider(LanguageGenerator::new); } private static class LanguageGenerator extends FabricLanguageProvider { - public LanguageGenerator(FabricDataGenerator gen) { + public LanguageGenerator(FabricDataOutput gen) { super(gen, "en_us"); } diff --git a/gradle.properties b/gradle.properties index 5b21218..4475a2b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,16 @@ org.gradle.jvmargs=-Xmx2048M -minecraft_version=1.19.2 +minecraft_version=1.20 enabled_platforms=fabric,forge archives_base_name=ToolKit -mod_version=2.3.8 +mod_version=3.0.0 maven_group=com.sunekaer.mods -architectury_version=6.5.77 +architectury_version=9.0.7 fabric_loader_version=0.14.21 -fabric_api_version=0.76.0+1.19.2 +fabric_api_version=0.83.0+1.20 -forge_version=1.19.2-43.2.8 +forge_version=1.20-46.0.12 curseforge_id=324888 diff --git a/settings.gradle b/settings.gradle index 6dd451f..3796348 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,4 +11,4 @@ include("common") include("fabric") include("forge") -rootProject.name = "toolkit" +rootProject.name = "ToolKit"