Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 04:50:06 +01:00
Make Slimes fire EntityTarget events. Fixes BUKKIT-1408
Dieser Commit ist enthalten in:
Ursprung
e62614a71e
Commit
0ab14dbaad
@ -1,6 +1,11 @@
|
|||||||
package net.minecraft.server;
|
package net.minecraft.server;
|
||||||
|
|
||||||
import org.bukkit.event.entity.SlimeSplitEvent; // CraftBukkit
|
// CraftBukkit start
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.SlimeSplitEvent;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntitySlime extends EntityLiving implements IMonster {
|
public class EntitySlime extends EntityLiving implements IMonster {
|
||||||
|
|
||||||
@ -9,6 +14,7 @@ public class EntitySlime extends EntityLiving implements IMonster {
|
|||||||
public float c;
|
public float c;
|
||||||
public float d;
|
public float d;
|
||||||
private int jumpDelay = 0;
|
private int jumpDelay = 0;
|
||||||
|
private Entity lastTarget; // CraftBukkit
|
||||||
|
|
||||||
public EntitySlime(World world) {
|
public EntitySlime(World world) {
|
||||||
super(world);
|
super(world);
|
||||||
@ -110,7 +116,22 @@ public class EntitySlime extends EntityLiving implements IMonster {
|
|||||||
|
|
||||||
protected void bq() {
|
protected void bq() {
|
||||||
this.bn();
|
this.bn();
|
||||||
EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // CraftBukkit TODO: EntityTargetEvent
|
// CraftBukkit start
|
||||||
|
Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity
|
||||||
|
EntityTargetEvent event = null;
|
||||||
|
|
||||||
|
if (entityhuman != null && !entityhuman.equals(lastTarget)) {
|
||||||
|
event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
|
||||||
|
} else if (lastTarget != null && entityhuman == null) {
|
||||||
|
event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event != null && !event.isCancelled()) {
|
||||||
|
entityhuman = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastTarget = entityhuman;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
if (entityhuman != null) {
|
if (entityhuman != null) {
|
||||||
this.a(entityhuman, 10.0F, 20.0F);
|
this.a(entityhuman, 10.0F, 20.0F);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren