summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorEvilSeph <evilseph@unaligned.org>2011-06-12 23:38:35 -0400
committerEvilSeph <evilseph@unaligned.org>2011-06-15 15:01:09 -0400
commit6f1d6a4ca8a226b091a938b48031d42abec6ff87 (patch)
treee591ae389568da3c039ffc835e8f165459835f65 /src/main/java
parente2c9e92d98d94931ce78c68d893c0d916fbbdf47 (diff)
downloadcraftbukkit-6f1d6a4ca8a226b091a938b48031d42abec6ff87.tar
craftbukkit-6f1d6a4ca8a226b091a938b48031d42abec6ff87.tar.gz
craftbukkit-6f1d6a4ca8a226b091a938b48031d42abec6ff87.tar.lz
craftbukkit-6f1d6a4ca8a226b091a938b48031d42abec6ff87.tar.xz
craftbukkit-6f1d6a4ca8a226b091a938b48031d42abec6ff87.zip
Fixed EntityTame event.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/EntityWolf.java44
-rw-r--r--src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java2
2 files changed, 25 insertions, 21 deletions
diff --git a/src/main/java/net/minecraft/server/EntityWolf.java b/src/main/java/net/minecraft/server/EntityWolf.java
index 4cd7ff71..2ca4e040 100644
--- a/src/main/java/net/minecraft/server/EntityWolf.java
+++ b/src/main/java/net/minecraft/server/EntityWolf.java
@@ -307,25 +307,23 @@ public class EntityWolf extends EntityAnimal {
}
if (!this.world.isStatic) {
+ // CraftBukkit start
if (this.random.nextInt(3) == 0) {
- // CraftBukkit start
EntityTameEvent event = CraftEventFactory.callEntityTameEvent(this, entityhuman);
- if (event.isCancelled()) {
- return false;
- }
+ if (!event.isCancelled()) {
// CraftBukkit end
-
- this.d(true);
- this.a((PathEntity) null);
- this.setSitting(true);
- this.health = 20;
- this.a(entityhuman.name);
- this.a(true);
- this.world.a(this, (byte) 7);
- } else {
- this.a(false);
- this.world.a(this, (byte) 6);
+ this.d(true);
+ this.a((PathEntity) null);
+ this.setSitting(true);
+ this.health = 20;
+ this.a(entityhuman.name);
+ this.a(true);
+ this.world.a(this, (byte) 7);
+ } else {
+ this.a(false);
+ this.world.a(this, (byte) 6);
+ }
}
}
@@ -421,12 +419,18 @@ public class EntityWolf extends EntityAnimal {
}
public void d(boolean flag) {
- byte b0 = this.datawatcher.a(16);
+ // CraftBukkit start
+ EntityTameEvent event = CraftEventFactory.callEntityTameEvent(this, null);
- if (flag) {
- this.datawatcher.b(16, Byte.valueOf((byte) (b0 | 4)));
- } else {
- this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -5)));
+ if (!event.isCancelled()) {
+ // CraftBukkit end
+ byte b0 = this.datawatcher.a(16);
+
+ if (flag) {
+ this.datawatcher.b(16, Byte.valueOf((byte) (b0 | 4)));
+ } else {
+ this.datawatcher.b(16, Byte.valueOf((byte) (b0 & -5)));
+ }
}
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index a21d1365..6074d072 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -238,7 +238,7 @@ public class CraftEventFactory {
*/
public static EntityTameEvent callEntityTameEvent(EntityLiving entity, EntityHuman tamer) {
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();
EntityTameEvent event = new EntityTameEvent(bukkitEntity, bukkitTamer);