Skip to content

Commit d026916

Browse files
Fix build errors
1 parent e055a15 commit d026916

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

src/main/java/com/thepinkhacker/commandsplus/server/command/HeadCommand.java

+17-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import net.minecraft.command.argument.BlockPosArgumentType;
1313
import net.minecraft.command.argument.EntityArgumentType;
1414
import net.minecraft.command.argument.GameProfileArgumentType;
15+
import net.minecraft.component.DataComponentTypes;
16+
import net.minecraft.component.type.ProfileComponent;
1517
import net.minecraft.item.ItemStack;
1618
import net.minecraft.item.Items;
1719
import net.minecraft.nbt.NbtCompound;
@@ -94,11 +96,8 @@ private static int give(ServerCommandSource source, Collection<ServerPlayerEntit
9496

9597
for (ServerPlayerEntity player : targets) {
9698
for (GameProfile profile : profiles) {
97-
final NbtCompound nbt = new NbtCompound();
98-
nbt.putString("SkullOwner", profile.getName());
99-
10099
final ItemStack stack = Items.PLAYER_HEAD.getDefaultStack();
101-
stack.setNbt(nbt);
100+
stack.set(DataComponentTypes.PROFILE, new ProfileComponent(profile));
102101

103102
player.giveItemStack(stack);
104103
i++;
@@ -131,10 +130,10 @@ private static int queryUUID(ServerCommandSource source, BlockPos pos) {
131130
ServerWorld world = source.getWorld();
132131

133132
if (world.getBlockEntity(pos) instanceof SkullBlockEntity head) {
134-
GameProfile owner = head.getOwner();
133+
ProfileComponent owner = head.getOwner();
135134

136135
if (owner != null) {
137-
source.sendFeedback(() -> copyText("commands.head.query.uuid.success", owner.getId().toString()), false);
136+
source.sendFeedback(() -> copyText("commands.head.query.uuid.success", owner.gameProfile().getId().toString()), false);
138137
i = 1;
139138
}
140139
}
@@ -148,10 +147,10 @@ private static int queryName(ServerCommandSource source, BlockPos pos) {
148147
ServerWorld world = source.getWorld();
149148

150149
if (world.getBlockEntity(pos) instanceof SkullBlockEntity head) {
151-
GameProfile owner = head.getOwner();
150+
ProfileComponent owner = head.getOwner();
152151

153152
if (owner != null) {
154-
source.sendFeedback(() -> copyText("commands.head.query.name.success", owner.getName()), false);
153+
source.sendFeedback(() -> copyText("commands.head.query.name.success", owner.gameProfile().getName()), false);
155154
i = 1;
156155
}
157156
}
@@ -179,7 +178,7 @@ private static Text copyText(String key, String copyText) {
179178
);
180179
}
181180

182-
private static int updateHead(ServerCommandSource source, BlockPos pos, GameProfile profile) {
181+
private static int updateHead(ServerCommandSource source, BlockPos pos, ProfileComponent profile) {
183182
int i = 0;
184183

185184
if (source.getWorld().getBlockEntity(pos) instanceof SkullBlockEntity entity) {
@@ -192,7 +191,15 @@ private static int updateHead(ServerCommandSource source, BlockPos pos, GameProf
192191
return i;
193192
}
194193

194+
private static int updateHead(ServerCommandSource source, BlockPos pos, GameProfile profile) {
195+
return updateHead(source, pos, new ProfileComponent(profile));
196+
}
197+
195198
private static int updateHead(ServerCommandSource source, BlockPos pos) {
196-
return updateHead(source, pos, source.getPlayer().getGameProfile());
199+
ServerPlayerEntity player = source.getPlayer();
200+
201+
if (player == null) return -1;
202+
203+
return updateHead(source, pos, player.getGameProfile());
197204
}
198205
}

src/main/java/com/thepinkhacker/commandsplus/server/command/NameCommand.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.minecraft.command.argument.EntityArgumentType;
99
import net.minecraft.command.argument.ItemSlotArgumentType;
1010
import net.minecraft.command.argument.MessageArgumentType;
11+
import net.minecraft.component.DataComponentTypes;
1112
import net.minecraft.entity.Entity;
1213
import net.minecraft.entity.LivingEntity;
1314
import net.minecraft.inventory.StackReference;
@@ -61,7 +62,7 @@ private static int nameItem(ServerCommandSource source, Collection<? extends Ent
6162
ItemStack itemStack = stackReference.get();
6263

6364
if (!itemStack.isEmpty()) {
64-
itemStack.setCustomName(Text.of(name));
65+
itemStack.set(DataComponentTypes.CUSTOM_NAME, Text.of(name));
6566
i++;
6667
}
6768
}

src/main/java/com/thepinkhacker/commandsplus/server/command/RideCommand.java

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
1010
import net.minecraft.command.CommandRegistryAccess;
1111
import net.minecraft.command.argument.EntityArgumentType;
12-
import net.minecraft.command.argument.RegistryEntryArgumentType;
12+
import net.minecraft.command.argument.RegistryEntryReferenceArgumentType;
1313
import net.minecraft.command.suggestion.SuggestionProviders;
1414
import net.minecraft.entity.Entity;
1515
import net.minecraft.entity.EntityType;
@@ -22,7 +22,6 @@
2222
import net.minecraft.server.command.ServerCommandSource;
2323
import net.minecraft.server.world.ServerWorld;
2424
import net.minecraft.text.Text;
25-
import net.minecraft.util.Identifier;
2625
import net.minecraft.util.math.Vec3d;
2726

2827
import java.util.Collection;
@@ -75,22 +74,22 @@ public void register(CommandDispatcher<ServerCommandSource> dispatcher, CommandR
7574
))
7675
)
7776
.then(CommandManager.literal("summon_rider")
78-
.then(CommandManager.argument("entity", RegistryEntryArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE))
77+
.then(CommandManager.argument("entity", RegistryEntryReferenceArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE))
7978
.suggests(SuggestionProviders.SUMMONABLE_ENTITIES)
8079
.executes(context -> summonRider(
8180
context.getSource(),
8281
EntityArgumentType.getEntity(context, "riders"),
83-
RegistryEntryArgumentType.getSummonableEntityType(context, "entity")
82+
RegistryEntryReferenceArgumentType.getSummonableEntityType(context, "entity")
8483
))
8584
)
8685
)
8786
.then(CommandManager.literal("summon_ride")
88-
.then(CommandManager.argument("entity", RegistryEntryArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE))
87+
.then(CommandManager.argument("entity", RegistryEntryReferenceArgumentType.registryEntry(registryAccess, RegistryKeys.ENTITY_TYPE))
8988
.suggests(SuggestionProviders.SUMMONABLE_ENTITIES)
9089
.executes(context -> summonRide(
9190
context.getSource(),
9291
EntityArgumentType.getEntity(context, "riders"),
93-
RegistryEntryArgumentType.getSummonableEntityType(context, "entity")
92+
RegistryEntryReferenceArgumentType.getSummonableEntityType(context, "entity")
9493
))
9594
)
9695
)
@@ -220,7 +219,7 @@ private static int summonRider(
220219

221220
if (rider != null) {
222221
if (rider instanceof MobEntity mobEntity) {
223-
mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null, null);
222+
mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null);
224223
}
225224

226225
if (world.spawnNewEntityAndPassengers(rider)) {
@@ -258,7 +257,7 @@ private static int summonRide(
258257

259258
if (ride != null) {
260259
if (ride instanceof MobEntity mobEntity) {
261-
mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null, null);
260+
mobEntity.initialize(world, world.getLocalDifficulty(mobEntity.getBlockPos()), SpawnReason.COMMAND, null);
262261
}
263262

264263
if (world.spawnNewEntityAndPassengers(ride)) {

0 commit comments

Comments
 (0)