[SOLVED] Text formatting (get registry name of block w/o mod_id)

Started by DoomsdayFire on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED] Text formatting (get registry name of block w/o mod_id)
Tue, 08/27/2024 - 18:42 (edited)
  • 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 ) )

https://imgur.com/a/TL7Y71a

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!

Edited by DoomsdayFire on Tue, 08/27/2024 - 18:42
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It is possible by using…
Tue, 08/27/2024 - 17:19

It is possible by using custom code
Custom code: registry_name.split(":")[1]

Joined Feb 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Bar1BoD Thank you so much!
Tue, 08/27/2024 - 18:41

@Bar1BoD Thank you so much!