From 7691c87df6ae10249dfc618feab7be21b966f4cb Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 23 Nov 2016 10:27:49 +1100 Subject: [PATCH] SPIGOT-2824: Llama Strength API --- nms-patches/EntityLlama.patch | 20 +++++++++++++++++++ .../bukkit/craftbukkit/entity/CraftLlama.java | 13 ++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 nms-patches/EntityLlama.patch diff --git a/nms-patches/EntityLlama.patch b/nms-patches/EntityLlama.patch new file mode 100644 index 0000000000..c3214d7e25 --- /dev/null +++ b/nms-patches/EntityLlama.patch @@ -0,0 +1,20 @@ +--- a/net/minecraft/server/EntityLlama.java ++++ b/net/minecraft/server/EntityLlama.java +@@ -20,7 +20,7 @@ + this.setSize(0.9F, 1.87F); + } + +- private void p(int i) { ++ public void p(int i) { // PAIL: private-> public, rename + this.datawatcher.set(EntityLlama.bG, Integer.valueOf(Math.max(1, Math.min(5, i)))); + } + +@@ -30,7 +30,7 @@ + this.p(1 + this.random.nextInt(i)); + } + +- public int dL() { ++ public int dL() { // PAIL: rename + return ((Integer) this.datawatcher.get(EntityLlama.bG)).intValue(); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index 9dde90faea..45e17db5d2 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -37,6 +37,19 @@ public class CraftLlama extends CraftChestedHorse implements Llama { return new CraftInventoryLlama(getHandle().inventoryChest); } + @Override + public int getStrength() { + return getHandle().dL(); + } + + @Override + public void setStrength(int strength) { + Preconditions.checkArgument(1 <= strength && strength <= 5, "strength must be [1,5]"); + if (strength == getStrength()) return; + getHandle().p(strength); + getHandle().dx(); + } + @Override public Horse.Variant getVariant() { return Horse.Variant.LLAMA;