From 4f15f4197b12fa61421536caa9d5ea144bbe42af Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Wed, 21 Aug 2024 18:01:58 +0100 Subject: [PATCH] Fix turtle owning player not being set Fixes #1948, fixes #1949 --- .../computercraft/shared/turtle/blocks/TurtleBlock.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/projects/common/src/main/java/dan200/computercraft/shared/turtle/blocks/TurtleBlock.java b/projects/common/src/main/java/dan200/computercraft/shared/turtle/blocks/TurtleBlock.java index 3718f7f60..f879fe3dd 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/turtle/blocks/TurtleBlock.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/turtle/blocks/TurtleBlock.java @@ -140,6 +140,15 @@ public class TurtleBlock extends AbstractComputerBlock 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) {