Started by
MamaLuigi
on
Topic category: Help with Minecraft modding (Java Edition)
I want to make a mod where any entities caught in the blast of a vanilla Creeper have something happen to them.
Heres how i want it to work: When a Creeper explodes, if any entity was near it, then have each of those entities run a procedure to themselves
I got something similar to this working where a creeper spreads moss on exploding. Make a procedure with the global trigger 'when explosion occurs,' and then check if there's a creeper in a very small radius. (Contrary to what the name implies, this procedure runs just before the explosion occurs- Which in basically all cases, will indicate it was a creeper that exploded.) Then, in the procedure, make an entity-iterator in a larger radius that runs your custom behavior for each entity. (Creeper blasts have about a 5 block radius, I think?)
Thanks! I'll try this
so would i set the square cube to have a size of 5 or 2.5?
i forogt to mention, i want to make it so any entities caught in the blast get the strength effect, so how would i do this?
it would help if you could send a image of the procedure
So, you want to make a new procedure. Where it asks for a global trigger at the top, choose 'when explosion occurs.'
Then, take an 'if' function, and have it check if 'entity exists in square cube of size (2) type (creeper)' You can find this function in the 'world' tab.
Inside the 'if' function, grab an entity iterator, also from the world tab. (It'll say 'for each entity as entity iterator at (x/y/z) in square cube of size (...).' Entity iterators take a position, and then executes something for each entity within its cube size, centered on its position. (So instead of just targeting one entity, it'll target everything in the cube. For an explosion, I use cube size 5- that is, 5 blocks in any direction from the explosion.)
To give stuff the strength effect, you would simply put 'Add potion effect (strength) to event/target entity' inside the entity iterator, but replace 'event/target entity' with 'entity iterator.' (You're not giving it an entity to apply strength to, but the entity iterator will apply strength to anything it finds inside the cube.) You can find potion functions in the 'entity management' tab, and 'entity iterator' in the 'minecraft components' tab.
it worked! thanks!