Topic category: Help with Minecraft modding (Java Edition)
- Solved by @BaR1BoD using custom code snippet, check out comments
I'm trying to get only registry name of block, since I transfer this to loot table drop in function
Example:
Procedure break blocks in 5x5 area, dropping for every block it's own drop using loot table
Drop item from loot table "blocks/registry_name", but function Get registry name of Local_block_coordinate gives "minecraft:stone", however we need just stone
to append it later to "block/HERE" w/o mod_id (minecraft)
So the task is not really complex, just to substring text from first " : " character
Is there any built-in function to do that?
How I resolved it:
Created local variable reg_name
While ( Does text "reg_name" contain " : " -> Set variable "reg_name" to ( Substring "reg_name" from position 1 ) )
Just simply cutting 1st character in each iteration until we get registry_name w/o " : " separator
But I can't sleep with it, 25(cause of 5x5 area) * 10 iterations (cause of "minecraft:" for example) = 250 uses of function per block break
Seems really unoptimized, but it works. So, can we format that an easier way?
Thanks for any advice!
It is possible by using custom code
Custom code:
registry_name.split(":")[1]
@Bar1BoD Thank you so much!