Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
EntityTargetEvent
Dieser Commit ist enthalten in:
Ursprung
0ba870434e
Commit
c07e32c1de
@ -5,6 +5,9 @@ import java.util.Random;
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
import org.bukkit.craftbukkit.entity.CraftCreature;
|
import org.bukkit.craftbukkit.entity.CraftCreature;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntityCreature extends EntityLiving {
|
public class EntityCreature extends EntityLiving {
|
||||||
@ -27,12 +30,37 @@ public class EntityCreature extends EntityLiving {
|
|||||||
float f = 16F;
|
float f = 16F;
|
||||||
|
|
||||||
if (d == null) {
|
if (d == null) {
|
||||||
d = l();
|
// CraftBukkit start
|
||||||
|
Entity target = l();
|
||||||
|
if(target != null) {
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), TargetReason.CLOSEST_PLAYER);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
a = l.a(((Entity) (this)), d, f);
|
a = l.a(((Entity) (this)), d, f);
|
||||||
}
|
}
|
||||||
} else if (!d.B()) {
|
} else if (!d.B()) {
|
||||||
|
// CraftBukkit start
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.TARGET_DIED);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
d = null;
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
} else {
|
} else {
|
||||||
float f1 = d.a(((Entity) (this)));
|
float f1 = d.a(((Entity) (this)));
|
||||||
|
|
||||||
|
@ -5,10 +5,13 @@ import java.util.Random;
|
|||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.entity.CraftMonster;
|
import org.bukkit.craftbukkit.entity.CraftMonster;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
|
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntityMobs extends EntityCreature implements IMobs {
|
public class EntityMobs extends EntityCreature implements IMobs {
|
||||||
@ -57,7 +60,22 @@ public class EntityMobs extends EntityCreature implements IMobs {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (entity != this) {
|
if (entity != this) {
|
||||||
d = entity;
|
// CraftBukkit start
|
||||||
|
org.bukkit.entity.Entity bukkitTarget = null;
|
||||||
|
if(entity != null) {
|
||||||
|
bukkitTarget = entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.TARGET_ATTACKED_ENTITY);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -5,7 +5,10 @@ import java.util.Random;
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.entity.CraftPigZombie;
|
import org.bukkit.craftbukkit.entity.CraftPigZombie;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
public class EntityPigZombie extends EntityZombie {
|
public class EntityPigZombie extends EntityZombie {
|
||||||
@ -82,10 +85,25 @@ public class EntityPigZombie extends EntityZombie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void g(Entity entity) {
|
private void g(Entity entity) {
|
||||||
d = entity;
|
// CraftBukkit start
|
||||||
|
org.bukkit.entity.Entity bukkitTarget = null;
|
||||||
|
if(entity != null) {
|
||||||
|
bukkitTarget = entity.getBukkitEntity();
|
||||||
|
}
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, TargetReason.PIG_ZOMBIE_TARGET);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
a = 400 + W.nextInt(400);
|
a = 400 + W.nextInt(400);
|
||||||
b = W.nextInt(40);
|
b = W.nextInt(40);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
}
|
||||||
|
|
||||||
protected String e() {
|
protected String e() {
|
||||||
return "mob.zombiepig.zpig";
|
return "mob.zombiepig.zpig";
|
||||||
|
@ -4,7 +4,10 @@ import java.util.Random;
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||||
import org.bukkit.craftbukkit.entity.CraftSpider;
|
import org.bukkit.craftbukkit.entity.CraftSpider;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||||
// CraftBukkit stop
|
// CraftBukkit stop
|
||||||
|
|
||||||
public class EntitySpider extends EntityMobs {
|
public class EntitySpider extends EntityMobs {
|
||||||
@ -52,9 +55,20 @@ public class EntitySpider extends EntityMobs {
|
|||||||
float f2 = b(1.0F);
|
float f2 = b(1.0F);
|
||||||
|
|
||||||
if (f2 > 0.5F && W.nextInt(100) == 0) {
|
if (f2 > 0.5F && W.nextInt(100) == 0) {
|
||||||
|
// CraftBukkit start
|
||||||
|
EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, TargetReason.FORGOT_TARGET);
|
||||||
|
CraftServer server = ((WorldServer) this.l).getServer();
|
||||||
|
server.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
if(event.getTarget() == null) {
|
||||||
this.d = null;
|
this.d = null;
|
||||||
|
} else {
|
||||||
|
this.d = ((CraftEntity) event.getTarget()).getHandle();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
}
|
||||||
if (f1 > 2.0F && f1 < 6F && W.nextInt(10) == 0) {
|
if (f1 > 2.0F && f1 < 6F && W.nextInt(10) == 0) {
|
||||||
if (A) {
|
if (A) {
|
||||||
double d = entity.p - p;
|
double d = entity.p - p;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren