mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-22 18:45:54 +01:00
SPIGOT-4526: Add conversion time API for Zombie & subclasses
This commit is contained in:
parent
c64fe5080c
commit
6ec8ea5cf4
@ -16,8 +16,17 @@
|
||||
public class EntityZombie extends EntityMonster {
|
||||
|
||||
protected static final IAttribute c = (new AttributeRanged((IAttribute) null, "zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).a("Spawn Reinforcements Chance");
|
||||
@@ -21,6 +30,7 @@
|
||||
private int drownedConversionTime;
|
||||
@@ -14,13 +23,14 @@
|
||||
private static final DataWatcherObject<Boolean> bC = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i);
|
||||
private static final DataWatcherObject<Integer> bD = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.b);
|
||||
private static final DataWatcherObject<Boolean> bE = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i);
|
||||
- private static final DataWatcherObject<Boolean> bF = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i);
|
||||
+ public static final DataWatcherObject<Boolean> bF = DataWatcher.a(EntityZombie.class, DataWatcherRegistry.i); // PAIL
|
||||
private final PathfinderGoalBreakDoor bG;
|
||||
private boolean bH;
|
||||
private int bI;
|
||||
- private int drownedConversionTime;
|
||||
+ public int drownedConversionTime; // PAIL
|
||||
private float bK;
|
||||
private float bL;
|
||||
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
||||
@ -39,7 +48,7 @@
|
||||
if (this.drownedConversionTime < 0) {
|
||||
this.dE();
|
||||
}
|
||||
@@ -182,7 +196,14 @@
|
||||
@@ -182,14 +196,21 @@
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
@ -55,6 +64,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
super.movementTick();
|
||||
}
|
||||
|
||||
- private void a(int i) {
|
||||
+ public void a(int i) { // PAIL
|
||||
this.drownedConversionTime = i;
|
||||
this.getDataWatcher().set(EntityZombie.bF, true);
|
||||
}
|
||||
@@ -221,7 +242,12 @@
|
||||
entityzombie.setCustomNameVisible(this.getCustomNameVisible());
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/server/EntityZombieVillager.java
|
||||
+++ b/net/minecraft/server/EntityZombieVillager.java
|
||||
@@ -2,6 +2,10 @@
|
||||
@@ -2,13 +2,18 @@
|
||||
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
@ -11,9 +11,11 @@
|
||||
|
||||
public class EntityZombieVillager extends EntityZombie {
|
||||
|
||||
@@ -9,6 +13,7 @@
|
||||
- private static final DataWatcherObject<Boolean> a = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.i);
|
||||
+ public static final DataWatcherObject<Boolean> a = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.i); // PAIL
|
||||
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.b);
|
||||
private int conversionTime;
|
||||
- private int conversionTime;
|
||||
+ public int conversionTime; // PAIL
|
||||
private UUID bD;
|
||||
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
||||
|
||||
@ -34,7 +36,12 @@
|
||||
|
||||
this.conversionTime -= i;
|
||||
if (this.conversionTime <= 0) {
|
||||
@@ -100,8 +110,10 @@
|
||||
@@ -96,12 +106,14 @@
|
||||
return (Boolean) this.getDataWatcher().get(EntityZombieVillager.a);
|
||||
}
|
||||
|
||||
- protected void a(@Nullable UUID uuid, int i) {
|
||||
+ public void a(@Nullable UUID uuid, int i) { // PAIL
|
||||
this.bD = uuid;
|
||||
this.conversionTime = i;
|
||||
this.getDataWatcher().set(EntityZombieVillager.a, true);
|
||||
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user