Started by
Bommelnator
on
Topic category: Help with Minecraft modding (Java Edition)
specifically i want to make a block that has a boss health bar and it checks for nearby other blocks of a specific type and if one of them gets destroyed the boss bar drops for the percent of blocks it just lost
On player tick update, check for your block in an area, use the 6x6x6 template as a base.
The larger the area the laggier it may become. I would use another condition to narrow down where your block boss would be, for example if it only spawns in one biome, check the player is in that biome before checking all the nearby blocks.
Then if your block boss exists in that area, set a player logic variable to true, use this for the condition of your overlay. The overlay being the boss bar. This will only work if one block boss is active at a time, use global integer variables for the block boss max and current health. On the block tick update, check for the blocks around itself, add them up to a number and save it to the block. Eg 10. Then it counts those blocks each tick, set the block bosses health through the global variables through this number. This will however cause the block boss to gain health if those blocks are placed around it.
i ended up using the bossbar command but for some reason the get number from text block does not work with execute command and get result
found out that the number from text block works with only numbers
but it still wont work even tho i made it remove the text and only leave the number but the command that changes the value of the boss bar wont work, also i made it log what it gets and i noticed that it seems to execute 2 times, once in render thread where it outputs 0 and once in server thread where it gets the right number
i got it working with some horrible workarounds
im still looking for a way to do it more efficently
you could also make the boss invulnerable and damage it by whatever percent of their HP you want.
whenever the block is broken
i already tried that and it didnt work
i got it working by using the code editor