From 0816d8a06f2ca54b000c0e20f5c116cd369ed45e Mon Sep 17 00:00:00 2001
From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io>
Date: Sat, 19 Nov 2016 18:53:57 +1100
Subject: [PATCH] Add additional APIs for Evoker / EvokerFangs

By: momothereal <momothereal.mc@gmail.com>
---
 paper-server/nms-patches/EntityEvoker.patch       | 15 +++++++++++++++
 .../bukkit/craftbukkit/entity/CraftEvoker.java    | 10 ++++++++++
 .../craftbukkit/entity/CraftEvokerFangs.java      | 15 ++++++++++++++-
 3 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 paper-server/nms-patches/EntityEvoker.patch

diff --git a/paper-server/nms-patches/EntityEvoker.patch b/paper-server/nms-patches/EntityEvoker.patch
new file mode 100644
index 0000000000..6d8b367a5a
--- /dev/null
+++ b/paper-server/nms-patches/EntityEvoker.patch
@@ -0,0 +1,15 @@
+--- a/net/minecraft/server/EntityEvoker.java
++++ b/net/minecraft/server/EntityEvoker.java
+@@ -76,6 +76,12 @@
+         this.datawatcher.set(EntityEvoker.a, Byte.valueOf((byte) i));
+     }
+ 
++    // CraftBukkit start
++    public int getSpell() {
++        return this.datawatcher.get(EntityEvoker.a).intValue();
++    }
++    // CraftBukkit end
++
+     private int di() {
+         return this.b;
+     }
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java
index a5eeee5e0c..6e888d57a7 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvoker.java
@@ -25,4 +25,14 @@ public class CraftEvoker extends CraftMonster implements Evoker {
     public EntityType getType() {
         return EntityType.EVOKER;
     }
+
+    @Override
+    public Spell getCurrentSpell() {
+        return Spell.values()[getHandle().getSpell()];
+    }
+
+    @Override
+    public void setCurrentSpell(Spell spell) {
+        getHandle().a(spell == null ? 0 : spell.ordinal());
+    }
 }
diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java
index a9f086bf3c..249756f577 100644
--- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java
+++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEvokerFangs.java
@@ -1,10 +1,11 @@
 package org.bukkit.craftbukkit.entity;
 
-import net.minecraft.server.Entity;
 import net.minecraft.server.EntityEvokerFangs;
+import net.minecraft.server.EntityLiving;
 import org.bukkit.craftbukkit.CraftServer;
 import org.bukkit.entity.EntityType;
 import org.bukkit.entity.EvokerFangs;
+import org.bukkit.entity.LivingEntity;
 
 public class CraftEvokerFangs extends CraftEntity implements EvokerFangs {
 
@@ -26,4 +27,16 @@ public class CraftEvokerFangs extends CraftEntity implements EvokerFangs {
     public EntityType getType() {
         return EntityType.EVOKER_FANGS;
     }
+
+    @Override
+    public LivingEntity getOwner() {
+        EntityLiving owner = getHandle().j(); // PAIL: rename
+
+        return (owner == null) ? null : (LivingEntity) owner.getBukkitEntity();
+    }
+
+    @Override
+    public void setOwner(LivingEntity owner) {
+        getHandle().a(owner == null ? null : ((CraftLivingEntity) owner).getHandle());
+    }
 }