Started by
AdinTheGalacti…
on
Topic category: Help with Minecraft modding (Java Edition)
I'm thinking of a boss linked to a block of some sort (like a core) that you need to destroy to beat. But I can't think well on how to code it. Any tips or tricks I could use?
You can just check for the block on for example XYZ (where this block is) on entity tick event. And if a player destroys it you doing the dark magic (extinguish/kill entity)
there's literally a "on block destroyed" trigger. just make a new proceedure, make it execute /kill @e[type=yourmod:yourmob, r=5], and then attatch it to the core block in the "on block destroyed" trigger.
The better way to do this would be with custom data properties. Have the block spawn an entity on random tick, and immediately set three integer properties for that entity to the position of the block. Then, on the entity's update tick, check if the block at their saved position is still the correct type, and kill them if it isn't. This way only the specific entity bound to the block is killed. When the entity is attacked, you can cancel the global trigger and do the particle effect by getting a vector between the current position and their saved position, and then generating particles at random intervals along said vector, with their velocity set in the same direction. (The beam thing is a bit more complicated, there's probably some better explanations out there.)