Started by
carnivowrist
on
Topic category: Help with Minecraft modding (Java Edition)
I'm trying to make a procedure in which each tick (or every X ticks) it will set the attack target of an entity to the nearest entity to it, but if i use "get nearest entity" it will select itself, and so if i make it the attack target, the entity attacks itself as it considers itself the nearest. I tried other things like "for each entity as 'entity iterator' at X Y Z" --> set the attack target to entity iterator, which works well but this sets the attack target of the entity to the furthest entity to it.. i have no solutions
okay then try,
im sorry but it gave me an error when saving the procedure.. do i have to change anything in the code?
huh what's the error
doesn't compile properly https://ibb.co/W4fKZpL8
i tried the code snippet in a different procedure alone too
oh it looks like this might be harder in older version,
can you show me the generated code for the trigger?
https://ibb.co/GQ2XFhtk
i put it up just like your screenshot
I'm really not sure but try this,
it works well! Now the problem is that it's messing with custom attacks for my entities
im sorry if im getting annoying lol but i can't change the invulnerability time, it's either 0 or forever if i could change it and have it set for example just 1 tick instead of 0 it would fix it
i also can't set it just for specific entities (like i tried adding 'if source entity= my entity')
huh you can't do it with this block?
and umm I'm really not sure why it would be making the invulnerability last forever...
ig you could try like,
oh /*code*/ was supposed to be
return;
okay well i can actually do it for specific entities like in your screenshot but i mean that if i change the number in the code snippet 'entity.invulnerableTime = 0;' to no matter what it seems to stay 0 and past a very big number (i tried most from 0 to 100) it glitches and entity is invincible (and red damage filter on entity doesn't appear)
oh um did you try the wait 1 ticks thing?
i tried it also didn't work
oh, dam, sorry I really don't know why that's happening or how to make a workaround..
ok then the reason i can't let it to be 0 is here: https://ibb.co/WWyC7wWs
basically i have a procedure which replaces the normal attack of an entity: it cancels the attack, plays an animation, and after a couple ticks it does a hit sound and do damage to the target
in the 'for each entity as entity iterator' i have it set up like this to check if the target of the entity is too far for attack or not, but the problem is that sometimes it does it double very randomly, plays the sound and damage two times, so if the invulnerable time is 0 it basically doubles the damage..
i need a way to make it so it checks the distance between an entity and another, correctly
if you don't know ill make a forum