|
3 | 3 | import net.bettercombat.BetterCombat;
|
4 | 4 | import net.minecraft.entity.Entity;
|
5 | 5 | import net.minecraft.entity.Tameable;
|
| 6 | +import net.minecraft.entity.decoration.AbstractDecorationEntity; |
6 | 7 | import net.minecraft.entity.mob.HostileEntity;
|
7 | 8 | import net.minecraft.entity.mob.MobEntity;
|
8 | 9 | import net.minecraft.entity.passive.PassiveEntity;
|
9 | 10 | import net.minecraft.entity.passive.VillagerEntity;
|
10 | 11 | import net.minecraft.entity.player.PlayerEntity;
|
11 | 12 |
|
| 13 | +import java.util.Arrays; |
| 14 | + |
12 | 15 | public class TargetHelper {
|
13 | 16 | public enum Relation {
|
14 | 17 | FRIENDLY, NEUTRAL, HOSTILE;
|
@@ -48,9 +51,27 @@ public static Relation getRelation(PlayerEntity attacker, Entity target) {
|
48 | 51 | if (target instanceof HostileEntity) {
|
49 | 52 | return Relation.coalesce(config.player_relation_to_hostiles, Relation.HOSTILE);
|
50 | 53 | }
|
| 54 | + if (target instanceof AbstractDecorationEntity) { |
| 55 | + return Relation.NEUTRAL; |
| 56 | + } |
51 | 57 | return Relation.coalesce(config.player_relation_to_other, Relation.HOSTILE);
|
52 | 58 | } else {
|
53 | 59 | return attacker.isTeammate(target) ? Relation.FRIENDLY : Relation.HOSTILE;
|
54 | 60 | }
|
55 | 61 | }
|
| 62 | + |
| 63 | + public static boolean isAttackableMount(Entity entity) { |
| 64 | + if (entity instanceof HostileEntity || isEntityHostileVehicle(entity.getEntityName())) { |
| 65 | + return true; |
| 66 | + } |
| 67 | + return BetterCombat.config.allow_attacking_mount; |
| 68 | + } |
| 69 | + |
| 70 | + public static boolean isEntityHostileVehicle(String entityName) { |
| 71 | + // An entity is a hostile vehicle via blacklist specifically |
| 72 | + var config = BetterCombat.config; |
| 73 | + return config.hostile_player_vehicles != null |
| 74 | + && config.hostile_player_vehicles.length > 0 |
| 75 | + && Arrays.asList(config.hostile_player_vehicles).contains(entityName); |
| 76 | + } |
56 | 77 | }
|
0 commit comments