From bd0868ae1e34d4d829dc80984a3b640048ac7a5f Mon Sep 17 00:00:00 2001 From: James Clarke Date: Mon, 5 Nov 2012 18:09:40 +0000 Subject: [PATCH] Implement API for Skeleton and Zombie types. Fixes BUKKIT-2818 --- .../java/net/minecraft/server/EntityZombie.java | 2 +- .../bukkit/craftbukkit/entity/CraftSkeleton.java | 10 ++++++++++ .../bukkit/craftbukkit/entity/CraftZombie.java | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 84c1d1153d..a0934a25e0 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -61,7 +61,7 @@ public class EntityZombie extends EntityMonster { } public void setBaby(boolean flag) { - this.getDataWatcher().watch(12, Byte.valueOf((byte) 1)); + this.getDataWatcher().watch(12, Byte.valueOf((byte) (flag ? 1 : 0))); // CraftBukkit - added flag } public boolean isVillager() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java index 3093341456..58da899412 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntitySkeleton; +import org.apache.commons.lang.Validate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Skeleton; @@ -25,4 +26,13 @@ public class CraftSkeleton extends CraftMonster implements Skeleton { public EntityType getType() { return EntityType.SKELETON; } + + public SkeletonType getSkeletonType() { + return SkeletonType.getType(getHandle().getSkeletonType()); + } + + public void setSkeletonType(SkeletonType type) { + Validate.notNull(type); + getHandle().setSkeletonType(type.getId()); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java index 12139e3118..619579d4ac 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java @@ -25,4 +25,20 @@ public class CraftZombie extends CraftMonster implements Zombie { public EntityType getType() { return EntityType.ZOMBIE; } + + public boolean isBaby() { + return getHandle().isBaby(); + } + + public void setBaby(boolean flag) { + getHandle().setBaby(flag); + } + + public boolean isVillager() { + return getHandle().isVillager(); + } + + public void setVillager(boolean flag) { + getHandle().setVillager(flag); + } }