Topic category: Help with MCreator software
Hi, I want to make a enchantment that makes the wood logs you break with an axe drop planks of the same wood type.
It could be made by adding a conditional per each wood type (if block at x y z = X_WOOD do Spawn gem at x y z of type X_PLANKS)
But I wondered then if it could be made on a simplier way that makes the code shorter and saves resources (and maybe gives better performance), like taking the display name of the wood block at x y z and with some text operations (like replace) convert its display name to the one of their corresponding planks, and using it to get the planks block
Will be there a procedure that does something like that on future versions or is there a way to code something like that?
Well yes with coding. If you need to get Item by it's id you can use:
ForgeRegistries.ITEMS.getValue(new ResourceLocation(*your string's name or string itself*))
for e.g: ForgeRegistries.ITEMS.getValue(new ResourceLocation("minecraft:bedrock")) returns bedrock item.
You can also use this for your own items
Can it be passed to a itemstack object (like with the "new ItemStack" method)?
Since I need it to spawn four item entities on the floor
Yes
I've been thinking about spawning the item with commands to an open area in the chunk and then get that item stack, after which you can just quickly despawn the item