Topic category: Help with Minecraft modding (Java Edition)
hii, so i have an item that, when used or dropped, will be despawned and replaced with an entity. this seems to work when the item is used while testing in mcreator's "run client" thing, but not when playing outside of it (not sure why :P). i have a check when spawning the entity that returns the entity early if it's null, and logs an error message with the entity's saved data, which is saved as a string in a custom data text tag for the item (ik it's probably not the best solution, but it seemed to work ._.). the item disappears and logs the error only when the item is used and not when it's dropped (using the item will launch the entity towards the direction the player is facing, with a force depending on how long the item was being used for)
i use the following code to save the data in a procedure's custom code snippet (returns a string):
CompoundTag tag = new CompoundTag();
savedEntity.saveWithoutId(tag);
tag.remove("Pos");
tag.remove("Motion");
tag.remove("UUID");
String nbtString = tag.toString();
and this to load it:
try {
CompoundTag parsedTag = TagParser.parseTag(data);
affected.load(parsedTag);
} catch (CommandSyntaxException e) {
e.printStackTrace();
}the procedure returns before the entity's data can be loaded, and when playing normally the item just disappears without spawning anything at all, although it does seem to work when playing through mcreator's test run instance
also, putting a log code block thing also shows that the procedure is called twice, and only one of the two times does it fail
the entity also has custom animations and was made in blockbench, and i use nerdy's better animations plugin for texture variants, i don't know if that matters :P
images of the procedures and the other stuff are here
i'm using mcreator 2026.1 (neoforge 21.1.190 for mc 1.21.1) on openSUSE Leap 16
As the first image shows, there is something that prevents bat from spawning, which results in null result value as spawning fails.
From the first screenshot, it is not clear what the spawn failure reason is.
If you believe return value is always null, open bug report at https://github.com/MCreator/MCreator/issues and make demo workspace with single simple procedure showing the procedure block always returns null