Jump to content

[1.16.5] saving tags to item via event interactLivingEntity not working in creative


Recommended Posts

Posted

I'm trying to overcome a little issue.  I'm trying to save data to an item's tag.  This works perfectly fine in survival but does not work in creative mode.  

 

 @Override
    public ActionResultType interactLivingEntity(ItemStack stack, PlayerEntity player, LivingEntity livingEntity, Hand hand) {
        if (hasAnimal(stack) || !livingEntity.isAlive() || livingEntity instanceof PlayerEntity) return ActionResultType.PASS;
        if (!player.level.isClientSide && livingEntity.isAlive() && livingEntity instanceof MonsterEntity) {
				CompoundNBT entityNBT = livingEntity.serializeNBT();
                stack.getOrCreateTag().put(NBT_ANIMAL,entityNBT);
				livingEntity.remove();
                return ActionResultType.SUCCESS;
		}
		return ActionResultType.PASS;
   }

 

I totally get if I was trying to do something like ItemStack.HurtAndBreak()  which would damage it, but the tags don't even populate with data once outside of this event (They are retrievable while still locally in the event and have access to the instance passed into the event).

The item in question is a single-stack item.

Switching to Survival rectifies this situation.

Is this expected? Normal?  If not am I doing something wrong?  

 

~BrewingCoder

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.