summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-12-13 14:10:36 +1100
committermd_5 <git@md-5.net>2018-12-13 14:10:36 +1100
commit6ec8ea5cf4f8db20562abdead706982d4e842943 (patch)
tree9c9c9d3852da9b0baeb77c2e0d92b13177753186 /src
parentc64fe5080c996e8ea29b3e113043dd0aa962aaee (diff)
downloadcraftbukkit-6ec8ea5cf4f8db20562abdead706982d4e842943.tar
craftbukkit-6ec8ea5cf4f8db20562abdead706982d4e842943.tar.gz
craftbukkit-6ec8ea5cf4f8db20562abdead706982d4e842943.tar.lz
craftbukkit-6ec8ea5cf4f8db20562abdead706982d4e842943.tar.xz
craftbukkit-6ec8ea5cf4f8db20562abdead706982d4e842943.zip
SPIGOT-4526: Add conversion time API for Zombie & subclasses
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java15
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java24
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java23
3 files changed, 62 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java
index 0e6ccea7..c8d66f31 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPigZombie.java
@@ -41,4 +41,19 @@ public class CraftPigZombie extends CraftZombie implements PigZombie {
public EntityType getType() {
return EntityType.PIG_ZOMBIE;
}
+
+ @Override
+ public boolean isConverting() {
+ return false;
+ }
+
+ @Override
+ public int getConversionTime() {
+ throw new UnsupportedOperationException("Not supported by this Entity.");
+ }
+
+ @Override
+ public void setConversionTime(int time) {
+ throw new UnsupportedOperationException("Not supported by this Entity.");
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java
index 6073d508..876129fd 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java
@@ -1,5 +1,7 @@
package org.bukkit.craftbukkit.entity;
+import com.google.common.base.Preconditions;
+import java.util.UUID;
import net.minecraft.server.EntityZombieVillager;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.EntityType;
@@ -36,4 +38,26 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager {
public void setVillagerProfession(Villager.Profession profession) {
getHandle().setProfession(profession == null ? 0 : profession.ordinal() - Villager.Profession.FARMER.ordinal());
}
+
+ @Override
+ public boolean isConverting() {
+ return getHandle().isConverting();
+ }
+
+ @Override
+ public int getConversionTime() {
+ Preconditions.checkState(isConverting(), "Entity not converting");
+
+ return getHandle().conversionTime;
+ }
+
+ @Override
+ public void setConversionTime(int time) {
+ if (time < 0) {
+ getHandle().conversionTime = -1;
+ getHandle().getDataWatcher().set(EntityZombieVillager.a, false);
+ } else {
+ getHandle().a((UUID) null, time);
+ }
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
index d2c3dbe4..7af4ea9f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
@@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.entity;
+import com.google.common.base.Preconditions;
import net.minecraft.server.EntityZombie;
import net.minecraft.server.EntityZombieVillager;
@@ -54,4 +55,26 @@ public class CraftZombie extends CraftMonster implements Zombie {
public Villager.Profession getVillagerProfession() {
return null;
}
+
+ @Override
+ public boolean isConverting() {
+ return getHandle().isDrownConverting();
+ }
+
+ @Override
+ public int getConversionTime() {
+ Preconditions.checkState(isConverting(), "Entity not converting");
+
+ return getHandle().drownedConversionTime;
+ }
+
+ @Override
+ public void setConversionTime(int time) {
+ if (time < 0) {
+ getHandle().drownedConversionTime = -1;
+ getHandle().getDataWatcher().set(EntityZombie.bF, false);
+ } else {
+ getHandle().a(time);
+ }
+ }
}