Started by
BudderYT
on
Topic category: Troubleshooting, bugs, and solutions
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.
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.
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'!