WhyWePlay Posted May 20, 2023 Share Posted May 20, 2023 Hey all. I've written this for my server, but it doesn't seem to want to work. no errors, just it doesn't seem to cancel the event. I know it would work if it was indented like for all of the lines, but i would like to find a more code efficient way. could anyone tell me a way this code could work like in this state, compressed? on damage of a entity: if victim is not a player: if attacker is a zombie, skeleton, ravager, or pillager: cancel event Link to comment Share on other sites More sharing options...
_Scribbly Posted May 21, 2023 Share Posted May 21, 2023 on damage: if victim is not player: if attacker is zombie or skeleton or ravager or pillager: cancel event I haven't tested this or anything yet but let me know if it works Link to comment Share on other sites More sharing options...
WhyWePlay Posted May 21, 2023 Author Share Posted May 21, 2023 14 hours ago, _Scribbly said: on damage: if victim is not player: if attacker is zombie or skeleton or ravager or pillager: cancel event I haven't tested this or anything yet but let me know if it works I tried it and it still seems to allow the mobs to hit each other. there is still no errors when reloading it. Link to comment Share on other sites More sharing options...
_Scribbly Posted May 21, 2023 Share Posted May 21, 2023 It may only be canceling the damage taken from the entity. The red flash and knockback will still occur. I don't know, are you trying to prevent mobs from attacking villagers? Maybe it could be made more direct, like: on damage of villager: if attacker is not player: cancel event Again, not tested Link to comment Share on other sites More sharing options...
WhyWePlay Posted May 21, 2023 Author Share Posted May 21, 2023 (edited) 19 minutes ago, _Scribbly said: It may only be canceling the damage taken from the entity. The red flash and knockback will still occur. I don't know, are you trying to prevent mobs from attacking villagers? Maybe it could be made more direct, like: on damage of villager: if attacker is not player: cancel event Again, not tested I am attempting to make it so mobs do not get damaged by other mobs i originally had the code on damage of a entity: if victim is not a player: cancel event which worked, but it also makes it so ./kill didn't work, so i was attempting to make it so only certain types of mobs couldn't damage the entity, it seems like there isn't really a simpler way to write this code, so ill just go with the one with 4 indentions. thanks for attempting it though Edited May 21, 2023 by WhyWePlay grammer Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now