From 5193f762a78208be3e917e2ece787aac7794da7f Mon Sep 17 00:00:00 2001 From: md_5 Date: Sun, 28 Apr 2019 17:59:12 +1000 Subject: [PATCH] SPIGOT-4803: Fox related APIs --- nms-patches/EntityFox.patch | 66 +++++++++++++++++++ .../bukkit/craftbukkit/entity/CraftFox.java | 38 +++++++++++ .../craftbukkit/entity/CraftHumanEntity.java | 5 -- .../craftbukkit/entity/CraftLivingEntity.java | 5 ++ 4 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 nms-patches/EntityFox.patch diff --git a/nms-patches/EntityFox.patch b/nms-patches/EntityFox.patch new file mode 100644 index 0000000000..fe02a5eed0 --- /dev/null +++ b/nms-patches/EntityFox.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/server/EntityFox.java ++++ b/net/minecraft/server/EntityFox.java +@@ -96,7 +96,7 @@ + this.goalSelector.a(10, new EntityFox.p()); + this.goalSelector.a(11, new EntityFox.j(this, EntityHuman.class, 24.0F)); + this.goalSelector.a(12, new EntityFox.r()); +- this.targetSelector.a(3, new EntityFox.a(EntityLiving.class, false, false, (entityliving) -> { ++ this.targetSelector.a(3, new EntityFox.a(EntityLiving.class, false, false, (entityliving) -> { // CraftBukkit - decompile error + return EntityFox.bF.test(entityliving) && !this.c(entityliving.getUniqueID()); + })); + } +@@ -260,15 +260,15 @@ + return EntityFox.Type.a((Integer) this.datawatcher.get(EntityFox.bz)); + } + +- private void a(EntityFox.Type entityfox_type) { ++ public void a(EntityFox.Type entityfox_type) { // PAIL + this.datawatcher.set(EntityFox.bz, entityfox_type.c()); + } + + private List ek() { + List list = Lists.newArrayList(); + +- list.add(((Optional) this.datawatcher.get(EntityFox.bB)).orElse((Object) null)); +- list.add(((Optional) this.datawatcher.get(EntityFox.bD)).orElse((Object) null)); ++ list.add((this.datawatcher.get(EntityFox.bB)).orElse(null)); // CraftBukkit - decompile error ++ list.add((this.datawatcher.get(EntityFox.bD)).orElse(null)); // CraftBukkit - decompile error + return list; + } + +@@ -348,7 +348,7 @@ + return this.r(32); + } + +- private void x(boolean flag) { ++ public void x(boolean flag) { // PAIL + this.d(32, flag); + } + +@@ -983,7 +983,7 @@ + private int f; + + public r() { +- super(null); ++ super(); // CraftBukkit - decompile error + this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK)); + } + +@@ -1035,7 +1035,7 @@ + private int c; + + public t() { +- super(null); ++ super(); // CraftBukkit - decompile error + this.c = EntityFox.this.random.nextInt(140); + this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK, PathfinderGoal.Type.JUMP)); + } +@@ -1146,7 +1146,7 @@ + private EntityLiving k; + private int l; + +- public a(Class oclass, boolean flag, boolean flag1, Predicate predicate) { ++ public a(Class oclass, boolean flag, boolean flag1, Predicate predicate) { // CraftBukkit - decompile error + super(EntityFox.this, oclass, 10, flag, flag1, predicate); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index 770b1111de..a78cad292a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.entity; +import com.google.common.base.Preconditions; import net.minecraft.server.EntityFox; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; @@ -25,4 +26,41 @@ public class CraftFox extends CraftAnimals implements Fox { public String toString() { return "CraftFox"; } + + @Override + public Type getFoxType() { + return Type.values()[getHandle().dV().ordinal()]; + } + + @Override + public void setFoxType(Type type) { + Preconditions.checkArgument(type != null, "type"); + + getHandle().a(EntityFox.Type.values()[type.ordinal()]); + } + + @Override + public boolean isCrouching() { + return getHandle().ef(); + } + + @Override + public void setCrouching(boolean crouching) { + getHandle().t(crouching); + } + + @Override + public boolean isSitting() { + return getHandle().dW(); + } + + @Override + public void setSitting(boolean sitting) { + getHandle().r(sitting); + } + + @Override + public void setSleeping(boolean sleeping) { + getHandle().x(sleeping); + } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index d36c924b54..626ec19e7d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -135,11 +135,6 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } } - @Override - public boolean isSleeping() { - return getHandle().isSleeping(); - } - @Override public int getSleepTicks() { return getHandle().sleepTicks; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 2b0671a708..9e7fc19129 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -551,6 +551,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { return getHandle().isRiptiding(); } + @Override + public boolean isSleeping() { + return getHandle().isSleeping(); + } + @Override public AttributeInstance getAttribute(Attribute attribute) { return getHandle().craftAttributes.getAttribute(attribute);