Started by
B0nesRC0οI
on
Topic category: Help with modding (Java Edition)
I need a way to simulate a right click event to have the player use a spawn egg. the problem is, the "Simulate Right Click of [entity] on Block at x: y: z:" block does not do what I need it to, and instead is only useful for making the player open a chest or whatever. If anyone knows a way to make what I need to happen, or some other work around (such as some way to summon the mob by looking at what the spawn egg is) It would be very much helpful.
Should say that this is meant to be used not only with vanilla mobs, but also with modded mobs as well so using any variation of a look up table won't work as it must be dynamic enough to work with any mob egg
Even if there was a way to do it with code it would be great. Also I've attached an image of the procedure I need to use it in.
I thought I had posted the image along with that last message, but I guess not.
I fixed the issue! And here's how I did it:
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Because spawn eggs follow the same naming scheme for their registry naming ( [MOB_NAME]_spawn_egg ) I just took the registry from the item with the "get registry name of:" procedure block, and used the "replace" text procedure block to replace "_spawn_egg" with "" (empty text) for the given registry name. I then used the "create text with:" block to combine "summon " (the space after the word is important) with the given text from the earlier procedures to create a text block saying "summon [MOB_NAME]", and put that on a "execute command [__] at [x] [y+1] [z]" and put the whole text block in.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Hope this helps someone!