mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
Make class pets aggro hostile mobs who attack their owners.
When a player takes damage from a hostile mob, the player's class pets will have their target set to that mob. This means that even zombies can function as "real" pets!
This commit is contained in:
parent
ab031e3e63
commit
b44b808d38
@ -13,7 +13,7 @@ These changes will (most likely) be included in the next version.
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
- Extended and upgraded potions are now supported in the item syntax by prepending `long_` or `strong_` to the data portion of a potion item (e.g. `potion:strong_instant_heal:1` will yield a Potion of Healing II). Check the wiki for details.
|
- Extended and upgraded potions are now supported in the item syntax by prepending `long_` or `strong_` to the data portion of a potion item (e.g. `potion:strong_instant_heal:1` will yield a Potion of Healing II). Check the wiki for details.
|
||||||
- MobArena now has basic tab completion support for most of the commands that take arguments.
|
- MobArena now has basic tab completion support for most of the commands that take arguments.
|
||||||
- The `pet-items` node in `global-settings` now supports any living entity as a pet (but only tameable entities will _behave_ as pets). This should allow 1.14 servers to replace `ocelot` with `cat` in their `pet-items` node to get cat pets working again.
|
- The `pet-items` node in `global-settings` now supports any living entity as a pet - even zombies! Pets will aggro hostile mobs that damage their owner, but only tameable pets (wolves, cats, etc.) will properly follow their owners around. This should also allow 1.14 servers to replace `ocelot` with `cat` in their `pet-items` node to get cat pets working again.
|
||||||
- Pets now have custom names that denote who their owner is, e.g. "garbagemule's pet".
|
- Pets now have custom names that denote who their owner is, e.g. "garbagemule's pet".
|
||||||
- Tridents and crossbows are now considered weapons with regards to the `unbreakable-weapons` flag. All class items that have durability now have their unbreakable flag set to true unless the `unbreakable-weapons` and/or `unbreakable-armor` flags are set to `false`.
|
- Tridents and crossbows are now considered weapons with regards to the `unbreakable-weapons` flag. All class items that have durability now have their unbreakable flag set to true unless the `unbreakable-weapons` and/or `unbreakable-armor` flags are set to `false`.
|
||||||
- Leaderboards now work again on servers running Minecraft 1.14+.
|
- Leaderboards now work again on servers running Minecraft 1.14+.
|
||||||
|
@ -32,6 +32,7 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.Slime;
|
import org.bukkit.entity.Slime;
|
||||||
@ -706,6 +707,19 @@ public class ArenaListener
|
|||||||
}
|
}
|
||||||
event.setCancelled(false);
|
event.setCancelled(false);
|
||||||
arena.getArenaPlayer(player).getStats().add("dmgTaken", event.getDamage());
|
arena.getArenaPlayer(player).getStats().add("dmgTaken", event.getDamage());
|
||||||
|
|
||||||
|
// Redirect pet aggro (but not at players)
|
||||||
|
if (damager instanceof LivingEntity && !(damager instanceof Player)) {
|
||||||
|
LivingEntity target = (LivingEntity) damager;
|
||||||
|
monsters.getPets(player).forEach(pet -> {
|
||||||
|
if (pet instanceof Mob) {
|
||||||
|
Mob mob = (Mob) pet;
|
||||||
|
if (mob.getTarget() == null) {
|
||||||
|
mob.setTarget(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user