Use Mob interface for on-spawn targeting.

Since 1.13, we've had the Mob interface injected between Creature and
LivingEntity, and it contains the targeting methods we use. Slimes were
never Creatures, but they _are_ Mobs, so by swapping this interface out,
we effectively patch up functionality that's been broken since the very
beginning. Hopefully server owners don't actually depend on this piece
of functionality being broken...
This commit is contained in:
Andreas Troelsen 2024-10-06 14:56:09 +02:00
parent 00b59ed7c4
commit b4db44985b
2 changed files with 5 additions and 4 deletions

View File

@ -20,6 +20,7 @@ These changes will (most likely) be included in the next version.
### Changed
- Recurrent waves can now be randomized. If two or more recurrent waves clash on wave number, frequency, _and_ priority, MobArena will now randomly pick between them. This should make it easier to create more varied and interesting wave setups without having to resort to only massively randomized default waves.
- Single waves can now be randomized. If two or more single waves clash on wave number, MobArena will now randomly pick between them. This means it is now possible to make randomly selected bosses for boss waves, for instance.
- Slimes, Magma Cubes, Bats, Ghasts, Phantoms, and Ender Dragons now all target players in the same way other monsters do.
### Fixed
- MobArena no longer throws errors when handling block explosions on Minecraft 1.21.

View File

@ -7,11 +7,11 @@ import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Bee;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Hoglin;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Mob;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.PiglinAbstract;
import org.bukkit.entity.Rabbit;
@ -181,9 +181,9 @@ public class MACreature {
break;
}
if (e instanceof Creature) {
Creature c = (Creature) e;
c.setTarget(WaveUtils.getClosestPlayer(arena, e));
if (e instanceof Mob) {
Mob m = (Mob) e;
m.setTarget(WaveUtils.getClosestPlayer(arena, e));
}
return e;