Setting Display Name of Entity to Item

Started by BudderYT on

Topic category: Troubleshooting, bugs, and solutions

Last seen on 17:01, 3. Dec 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Setting Display Name of Entity to Item

When setting a display name of an entity to display the name of an item in hand when is the default name. I have tried having the game set an nbt text tag value called name and having the entity named off of that but getting the same error.

 

https://imgur.com/a/c2iwC1N

 

Last seen on 17:47, 14. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The error you're getting is…
Mon, 10/30/2023 - 11:51

The error you're getting is probably just because you're using a very small radius for the 'get nearest entity' functions. Any time a 'get nearest entity' function isn't able to find an entity, it for some reason just crashes the game instead of, say, canceling the procedure, which is annoying, but mostly just means you want to turn up the radius.

In terms of the actual function, I assume you're trying to make a bucket that spawns an entity, but saves custom names given to it by the player. I actually did something pretty similar with beetles! Here's the function I used to make beetle bottles that save an entity's name:

If 'Release' is true, (if the player is sneaking), when they right click with the item in their main hand, it spawns the entity, and launches it a bit in the direction the player is looking. It also saves custom names, so if you name the bottle, the entity that spawns will also be named correctly. (This is a bit outdated actually, you should probably check that the display name equals the localization key, not the actual name, otherwise it won't work correctly if you ever want to translate your mod.) 

The important bit is that it checks for an entity in a much larger box, (so it's basically guaranteed to find it even if something weird happens), and also first checks that one does exist so if something somehow does go wrong, it at least doesn't crash the game. 

Last seen on 17:01, 3. Dec 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This 100% worked thank you…
Wed, 11/01/2023 - 20:05

This 100% worked thank you so much! I also found out it was cause I forgot a not value in the get display of 'provided item stack'!