Started by
No3
on
Topic category: Help with Minecraft modding (Java Edition)
Hi, I was trying to make sort of a soldier mob, which you can decide who it belongs to and who will it attack. I initially tried to do it through IDs made with NBT tags, by checking whether the other "soldier" had matching IDs (So 2 and 2) or different (5 and 72). Issue is, attack conditions don't support both event/target entity and source entity. I also tried taming, but tamed soldiers will attack other tamed soldiers... Is there a way to do this?
Basically I want Soldier A to attack Soldier B if I wish to, but I also want to be able to set Soldier B as an ally troop (without having to interact myself with Soldier B such as in hitting them or viceversa)
Edited by No3 on Thu, 11/24/2022 - 03:20
have you tried using the block "Get entity Event/Target Entity is targeting for attack"? this block does not require source entity to work.
I tried to do that, but the game just crashes the moment both entities see each other
Okay finally found a solution:
Doing it through NBTs so far crashes every attempt.
Doing it through tamed mobs doesn't work for some strange reason (there's always a chance that im dumb but hey)
So I tried an alternative method: Items
I made the attack condition check whether the item that mob A has in its main-hand is the same as mob B's. If it's the same, they are allies, if it's different, they are enemies. Doing it this way works like wonders, I made an item to be able to change their man-hand item (which doesn't physically show upbecause it's a custom entity but that's a good thing for me), and everytime I match their items, they stop attacking, and begin their attack again as soon as their items don't match up.
Very good solution but could you please show an image of the procedure or procedures, that way it would be much better.