From d02691682e9d4deec245b83fc279762229316240 Mon Sep 17 00:00:00 2001 From: Pink Garrett Date: Sun, 16 Jun 2024 03:18:33 -0400 Subject: [PATCH] Fix build errors --- .../server/command/HeadCommand.java | 27 ++++++++++++------- .../server/command/NameCommand.java | 3 ++- .../server/command/RideCommand.java | 15 +++++------ 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/thepinkhacker/commandsplus/server/command/HeadCommand.java b/src/main/java/com/thepinkhacker/commandsplus/server/command/HeadCommand.java index 05ba3ff..85110ba 100644 --- a/src/main/java/com/thepinkhacker/commandsplus/server/command/HeadCommand.java +++ b/src/main/java/com/thepinkhacker/commandsplus/server/command/HeadCommand.java @@ -12,6 +12,8 @@ import net.minecraft.command.argument.BlockPosArgumentType; import net.minecraft.command.argument.EntityArgumentType; import net.minecraft.command.argument.GameProfileArgumentType; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.ProfileComponent; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; @@ -94,11 +96,8 @@ private static int give(ServerCommandSource source, Collection copyText("commands.head.query.uuid.success", owner.getId().toString()), false); + source.sendFeedback(() -> copyText("commands.head.query.uuid.success", owner.gameProfile().getId().toString()), false); i = 1; } } @@ -148,10 +147,10 @@ private static int queryName(ServerCommandSource source, BlockPos pos) { ServerWorld world = source.getWorld(); if (world.getBlockEntity(pos) instanceof SkullBlockEntity head) { - GameProfile owner = head.getOwner(); + ProfileComponent owner = head.getOwner(); if (owner != null) { - source.sendFeedback(() -> copyText("commands.head.query.name.success", owner.getName()), false); + source.sendFeedback(() -> copyText("commands.head.query.name.success", owner.gameProfile().getName()), false); i = 1; } } @@ -179,7 +178,7 @@ private static Text copyText(String key, String copyText) { ); } - private static int updateHead(ServerCommandSource source, BlockPos pos, GameProfile profile) { + private static int updateHead(ServerCommandSource source, BlockPos pos, ProfileComponent profile) { int i = 0; if (source.getWorld().getBlockEntity(pos) instanceof SkullBlockEntity entity) { @@ -192,7 +191,15 @@ private static int updateHead(ServerCommandSource source, BlockPos pos, GameProf return i; } + private static int updateHead(ServerCommandSource source, BlockPos pos, GameProfile profile) { + return updateHead(source, pos, new ProfileComponent(profile)); + } + private static int updateHead(ServerCommandSource source, BlockPos pos) { - return updateHead(source, pos, source.getPlayer().getGameProfile()); + ServerPlayerEntity player = source.getPlayer(); + + if (player == null) return -1; + + return updateHead(source, pos, player.getGameProfile()); } } diff --git a/src/main/java/com/thepinkhacker/commandsplus/server/command/NameCommand.java b/src/main/java/com/thepinkhacker/commandsplus/server/command/NameCommand.java index ffc2872..2aa3d0d 100644 --- a/src/main/java/com/thepinkhacker/commandsplus/server/command/NameCommand.java +++ b/src/main/java/com/thepinkhacker/commandsplus/server/command/NameCommand.java @@ -8,6 +8,7 @@ import net.minecraft.command.argument.EntityArgumentType; import net.minecraft.command.argument.ItemSlotArgumentType; import net.minecraft.command.argument.MessageArgumentType; +import net.minecraft.component.DataComponentTypes; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.StackReference; @@ -61,7 +62,7 @@ private static int nameItem(ServerCommandSource source, Collection dispatcher, CommandR )) ) .then(CommandManager.literal("summon_rider") - .then(CommandManager.argument("entity", RegistryEntryArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE)) + .then(CommandManager.argument("entity", RegistryEntryReferenceArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE)) .suggests(SuggestionProviders.SUMMONABLE_ENTITIES) .executes(context -> summonRider( context.getSource(), EntityArgumentType.getEntity(context, "riders"), - RegistryEntryArgumentType.getSummonableEntityType(context, "entity") + RegistryEntryReferenceArgumentType.getSummonableEntityType(context, "entity") )) ) ) .then(CommandManager.literal("summon_ride") - .then(CommandManager.argument("entity", RegistryEntryArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE)) + .then(CommandManager.argument("entity", RegistryEntryReferenceArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE)) .suggests(SuggestionProviders.SUMMONABLE_ENTITIES) .executes(context -> summonRide( context.getSource(), EntityArgumentType.getEntity(context, "riders"), - RegistryEntryArgumentType.getSummonableEntityType(context, "entity") + RegistryEntryReferenceArgumentType.getSummonableEntityType(context, "entity") )) ) ) @@ -220,7 +219,7 @@ private static int summonRider( if (rider != null) { if (rider instanceof MobEntity mobEntity) { - mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null, null); + mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null); } if (world.spawnNewEntityAndPassengers(rider)) { @@ -258,7 +257,7 @@ private static int summonRide( if (ride != null) { if (ride instanceof MobEntity mobEntity) { - mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null, null); + mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null); } if (world.spawnNewEntityAndPassengers(ride)) {