Skip to content

Commit

Permalink
Fix turtle owning player not being set
Browse files Browse the repository at this point in the history
Fixes #1948, fixes #1949
  • Loading branch information
SquidDev committed Aug 21, 2024
1 parent 0d8ac30 commit 4f15f41
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ protected final void onRemove(BlockState state, Level level, BlockPos pos, Block
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) {
Expand Down

0 comments on commit 4f15f41

Please sign in to comment.