1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-25 08:26:54 +00:00

Fix turtle owning player not being set

Fixes #1948, fixes #1949
This commit is contained in:
Jonathan Coates 2024-08-21 18:01:58 +01:00
parent 0d8ac304c7
commit 4f15f4197b
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -140,6 +140,15 @@ public class TurtleBlock extends AbstractComputerBlock<TurtleBlockEntity> implem
if (turtle != null) Containers.dropContents(level, pos, turtle);
}
@Override
public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity entity, ItemStack stack) {
super.setPlacedBy(level, pos, state, entity, stack);
if (!level.isClientSide && level.getBlockEntity(pos) instanceof TurtleBlockEntity turtle && entity instanceof Player player) {
turtle.setOwningPlayer(player.getGameProfile());
}
}
@Override
protected ItemInteractionResult useItemOn(ItemStack currentItem, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (currentItem.getItem() == Items.NAME_TAG && currentItem.has(DataComponents.CUSTOM_NAME) && level.getBlockEntity(pos) instanceof AbstractComputerBlockEntity computer) {