3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 05:20:07 +01:00

Fixed EntityTame event.

Dieser Commit ist enthalten in:
EvilSeph 2011-06-12 23:38:35 -04:00
Ursprung e2c9e92d98
Commit 6f1d6a4ca8
2 geänderte Dateien mit 25 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -307,25 +307,23 @@ public class EntityWolf extends EntityAnimal {
} }
if (!this.world.isStatic) { if (!this.world.isStatic) {
// CraftBukkit start
if (this.random.nextInt(3) == 0) { if (this.random.nextInt(3) == 0) {
// CraftBukkit start
EntityTameEvent event = CraftEventFactory.callEntityTameEvent(this, entityhuman); EntityTameEvent event = CraftEventFactory.callEntityTameEvent(this, entityhuman);
if (event.isCancelled()) { if (!event.isCancelled()) {
return false;
}
// CraftBukkit end // CraftBukkit end
this.d(true);
this.d(true); this.a((PathEntity) null);
this.a((PathEntity) null); this.setSitting(true);
this.setSitting(true); this.health = 20;
this.health = 20; this.a(entityhuman.name);
this.a(entityhuman.name); this.a(true);
this.a(true); this.world.a(this, (byte) 7);
this.world.a(this, (byte) 7); } else {
} else { this.a(false);
this.a(false); this.world.a(this, (byte) 6);
this.world.a(this, (byte) 6); }
} }
} }
@ -421,12 +419,18 @@ public class EntityWolf extends EntityAnimal {
} }
public void d(boolean flag) { public void d(boolean flag) {
byte b0 = this.datawatcher.a(16); // CraftBukkit start
EntityTameEvent event = CraftEventFactory.callEntityTameEvent(this, null);
if (flag) { if (!event.isCancelled()) {
this.datawatcher.b(16, Byte.valueOf((byte) (b0 | 4))); // CraftBukkit end
} else { byte b0 = this.datawatcher.a(16);
this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -5)));
if (flag) {
this.datawatcher.b(16, Byte.valueOf((byte) (b0 | 4)));
} else {
this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -5)));
}
} }
} }
} }

Datei anzeigen

@ -238,7 +238,7 @@ public class CraftEventFactory {
*/ */
public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityHuman tamer) { public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityHuman tamer) {
org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
org.bukkit.entity.AnimalTamer bukkitTamer = (AnimalTamer) tamer.getBukkitEntity(); org.bukkit.entity.AnimalTamer bukkitTamer = (tamer != null ? (AnimalTamer) tamer.getBukkitEntity() : null);
CraftServer craftServer = (CraftServer) bukkitEntity.getServer(); CraftServer craftServer = (CraftServer) bukkitEntity.getServer();
EntityTameEvent event = new EntityTameEvent(bukkitEntity, bukkitTamer); EntityTameEvent event = new EntityTameEvent(bukkitEntity, bukkitTamer);