Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
the-pink-hacker committed Jun 16, 2024
1 parent e055a15 commit d026916
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,11 +96,8 @@ private static int give(ServerCommandSource source, Collection<ServerPlayerEntit

for (ServerPlayerEntity player : targets) {
for (GameProfile profile : profiles) {
final NbtCompound nbt = new NbtCompound();
nbt.putString("SkullOwner", profile.getName());

final ItemStack stack = Items.PLAYER_HEAD.getDefaultStack();
stack.setNbt(nbt);
stack.set(DataComponentTypes.PROFILE, new ProfileComponent(profile));

player.giveItemStack(stack);
i++;
Expand Down Expand Up @@ -131,10 +130,10 @@ private static int queryUUID(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.uuid.success", owner.getId().toString()), false);
source.sendFeedback(() -> copyText("commands.head.query.uuid.success", owner.gameProfile().getId().toString()), false);
i = 1;
}
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -61,7 +62,7 @@ private static int nameItem(ServerCommandSource source, Collection<? extends Ent
ItemStack itemStack = stackReference.get();

if (!itemStack.isEmpty()) {
itemStack.setCustomName(Text.of(name));
itemStack.set(DataComponentTypes.CUSTOM_NAME, Text.of(name));
i++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.argument.EntityArgumentType;
import net.minecraft.command.argument.RegistryEntryArgumentType;
import net.minecraft.command.argument.RegistryEntryReferenceArgumentType;
import net.minecraft.command.suggestion.SuggestionProviders;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
Expand All @@ -22,7 +22,6 @@
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;

import java.util.Collection;
Expand Down Expand Up @@ -75,22 +74,22 @@ public void register(CommandDispatcher<ServerCommandSource> 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")
))
)
)
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit d026916

Please sign in to comment.