From 278780623dcbf3e83629f46fea4dae97afd04ec0 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 26 Jun 2018 22:08:01 -0400
Subject: [PATCH] RangedEntity API

Allows you to determine if an entity is capable of ranged attacks,
and to perform an attack.
---
 .../LivingEntity-setKiller.patch              |   2 +-
 Spigot-API-Patches/RangedEntity-API.patch     | 132 +++++++++++++++
 Spigot-Server-Patches/RangedEntity-API.patch  | 160 ++++++++++++++++++
 scripts/importmcdev.sh                        |   1 +
 4 files changed, 294 insertions(+), 1 deletion(-)
 create mode 100644 Spigot-API-Patches/RangedEntity-API.patch
 create mode 100644 Spigot-Server-Patches/RangedEntity-API.patch

diff --git a/Spigot-API-Patches/LivingEntity-setKiller.patch b/Spigot-API-Patches/LivingEntity-setKiller.patch
index e5beed2d76..d1c3f44e57 100644
--- a/Spigot-API-Patches/LivingEntity-setKiller.patch
+++ b/Spigot-API-Patches/LivingEntity-setKiller.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] LivingEntity#setKiller
 
 
 diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
-index be51e389..4a51c519 100644
+index 4fafedc9..42cf95e1 100644
 --- a/src/main/java/org/bukkit/entity/LivingEntity.java
 +++ b/src/main/java/org/bukkit/entity/LivingEntity.java
 @@ -0,0 +0,0 @@ import org.bukkit.potion.PotionEffect;
diff --git a/Spigot-API-Patches/RangedEntity-API.patch b/Spigot-API-Patches/RangedEntity-API.patch
new file mode 100644
index 0000000000..36ec9c8a4f
--- /dev/null
+++ b/Spigot-API-Patches/RangedEntity-API.patch
@@ -0,0 +1,132 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <aikar@aikar.co>
+Date: Tue, 26 Jun 2018 21:34:40 -0400
+Subject: [PATCH] RangedEntity API
+
+Allows you to determine if an entity is capable of ranged attacks,
+and to perform an attack.
+
+diff --git a/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java
+new file mode 100644
+index 00000000..5153efab
+--- /dev/null
++++ b/src/main/java/com/destroystokyo/paper/entity/RangedEntity.java
+@@ -0,0 +0,0 @@
++package com.destroystokyo.paper.entity;
++
++import org.bukkit.entity.LivingEntity;
++
++public interface RangedEntity extends SentientNPC {
++    /**
++     * Attack the specified entity using a ranged attack.
++     *
++     * @param charge How "charged" the attack is (how far back the bow was pulled for Bow attacks).
++     *               This should be a value between 0 and 1, represented as targetDistance/maxDistance.
++     */
++    void rangedAttack(LivingEntity target, float charge);
++
++    /**
++     * Sets that the Entity is "charging" up an attack, by raising its arms
++     * @param charging Whether the entities arms are raised to charge attack
++     */
++    void setChargingAttack(boolean charging);
++}
+diff --git a/src/main/java/org/bukkit/entity/Illusioner.java b/src/main/java/org/bukkit/entity/Illusioner.java
+index 7c92c431..14e6c5ee 100644
+--- a/src/main/java/org/bukkit/entity/Illusioner.java
++++ b/src/main/java/org/bukkit/entity/Illusioner.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.entity;
+ 
++import com.destroystokyo.paper.entity.RangedEntity;
++
+ /**
+  * Represents an Illusioner "Illager".
+  */
+-public interface Illusioner extends Spellcaster { }
++public interface Illusioner extends Spellcaster, RangedEntity { // Paper
++
++}
+diff --git a/src/main/java/org/bukkit/entity/Llama.java b/src/main/java/org/bukkit/entity/Llama.java
+index 9422d56c..92c30ed5 100644
+--- a/src/main/java/org/bukkit/entity/Llama.java
++++ b/src/main/java/org/bukkit/entity/Llama.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.entity;
+ 
++import com.destroystokyo.paper.entity.RangedEntity;
+ import org.bukkit.inventory.LlamaInventory;
+ 
+ /**
+  * Represents a Llama.
+  */
+-public interface Llama extends ChestedHorse {
++public interface Llama extends ChestedHorse, RangedEntity { // Paper
+ 
+     /**
+      * Represents the base color that the llama has.
+diff --git a/src/main/java/org/bukkit/entity/Skeleton.java b/src/main/java/org/bukkit/entity/Skeleton.java
+index e33d00b3..40157bef 100644
+--- a/src/main/java/org/bukkit/entity/Skeleton.java
++++ b/src/main/java/org/bukkit/entity/Skeleton.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.entity;
+ 
++import com.destroystokyo.paper.entity.RangedEntity;
++
+ /**
+  * Represents a Skeleton.
+  */
+-public interface Skeleton extends Monster {
++public interface Skeleton extends Monster, RangedEntity { // Paper
+ 
+     /**
+      * Gets the current type of this skeleton.
+diff --git a/src/main/java/org/bukkit/entity/Snowman.java b/src/main/java/org/bukkit/entity/Snowman.java
+index 818efe2a..10f8f6d4 100644
+--- a/src/main/java/org/bukkit/entity/Snowman.java
++++ b/src/main/java/org/bukkit/entity/Snowman.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.entity;
+ 
++import com.destroystokyo.paper.entity.RangedEntity;
++
+ /**
+  * Represents a snowman entity
+  */
+-public interface Snowman extends Golem {
++public interface Snowman extends Golem, RangedEntity { // Paper
+ 
+     /**
+      * Gets whether this snowman is in "derp mode", meaning it is not wearing a
+diff --git a/src/main/java/org/bukkit/entity/Witch.java b/src/main/java/org/bukkit/entity/Witch.java
+index 9c5dc1f9..4b27f689 100644
+--- a/src/main/java/org/bukkit/entity/Witch.java
++++ b/src/main/java/org/bukkit/entity/Witch.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.entity;
+ 
++import com.destroystokyo.paper.entity.RangedEntity;
++
+ /**
+  * Represents a Witch
+  */
+-public interface Witch extends Monster {
++public interface Witch extends Monster, RangedEntity { // Paper
+ }
+diff --git a/src/main/java/org/bukkit/entity/Wither.java b/src/main/java/org/bukkit/entity/Wither.java
+index 0922c5c6..c550ed06 100644
+--- a/src/main/java/org/bukkit/entity/Wither.java
++++ b/src/main/java/org/bukkit/entity/Wither.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.entity;
+ 
++import com.destroystokyo.paper.entity.RangedEntity;
++
+ /**
+  * Represents a Wither boss
+  */
+-public interface Wither extends Monster {
++public interface Wither extends Monster, RangedEntity { // Paper
+ }
+--
\ No newline at end of file
diff --git a/Spigot-Server-Patches/RangedEntity-API.patch b/Spigot-Server-Patches/RangedEntity-API.patch
new file mode 100644
index 0000000000..cdb999c693
--- /dev/null
+++ b/Spigot-Server-Patches/RangedEntity-API.patch
@@ -0,0 +1,160 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <aikar@aikar.co>
+Date: Tue, 26 Jun 2018 22:00:49 -0400
+Subject: [PATCH] RangedEntity API
+
+Allows you to determine if an entity is capable of ranged attacks,
+and to perform an attack.
+
+diff --git a/src/main/java/com/destroystokyo/paper/entity/CraftRangedEntity.java b/src/main/java/com/destroystokyo/paper/entity/CraftRangedEntity.java
+new file mode 100644
+index 000000000..d85e4a203
+--- /dev/null
++++ b/src/main/java/com/destroystokyo/paper/entity/CraftRangedEntity.java
+@@ -0,0 +0,0 @@
++package com.destroystokyo.paper.entity;
++
++import net.minecraft.server.IRangedEntity;
++import org.bukkit.craftbukkit.entity.CraftLivingEntity;
++import org.bukkit.entity.LivingEntity;
++
++public interface CraftRangedEntity<T extends IRangedEntity> extends RangedEntity {
++    T getHandle();
++
++    @Override
++    default void rangedAttack(LivingEntity target, float charge) {
++        getHandle().rangedAttack(((CraftLivingEntity) target).getHandle(), charge);
++    }
++
++    @Override
++    default void setChargingAttack(boolean charging) {
++        getHandle().setChargingAttack(charging);
++    }
++}
+diff --git a/src/main/java/net/minecraft/server/IRangedEntity.java b/src/main/java/net/minecraft/server/IRangedEntity.java
+index a8af5917c..ba8b47c02 100644
+--- a/src/main/java/net/minecraft/server/IRangedEntity.java
++++ b/src/main/java/net/minecraft/server/IRangedEntity.java
+@@ -0,0 +0,0 @@ package net.minecraft.server;
+ 
+ public interface IRangedEntity {
+ 
+-    void a(EntityLiving entityliving, float f);
++    void a(EntityLiving entityliving, float f); default void rangedAttack(EntityLiving entityliving, float f) { a(entityliving, f); } // Paper OBF HELPER
+ 
+-    void p(boolean flag);
++
++    void p(boolean flag); default void setChargingAttack(boolean flag) { p(flag); } // Paper OBF HELPER
+ }
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java
+index 2ec1af8be..f31d3eed3 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.craftbukkit.entity;
+ 
++import com.destroystokyo.paper.entity.CraftRangedEntity;
+ import net.minecraft.server.EntityIllagerIllusioner;
+ import org.bukkit.craftbukkit.CraftServer;
+ import org.bukkit.entity.EntityType;
+ import org.bukkit.entity.Illusioner;
+ 
+-public class CraftIllusioner extends CraftSpellcaster implements Illusioner {
++public class CraftIllusioner extends CraftSpellcaster implements Illusioner, CraftRangedEntity<EntityIllagerIllusioner> { // Paper
+ 
+     public CraftIllusioner(CraftServer server, EntityIllagerIllusioner entity) {
+         super(server, entity);
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
+index 23ab78da1..3f94c5a92 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.craftbukkit.entity;
+ 
++import com.destroystokyo.paper.entity.CraftRangedEntity;
+ import com.google.common.base.Preconditions;
+ import net.minecraft.server.EntityLlama;
+ import org.bukkit.craftbukkit.CraftServer;
+@@ -0,0 +0,0 @@ import org.bukkit.entity.Horse;
+ import org.bukkit.entity.Llama;
+ import org.bukkit.inventory.LlamaInventory;
+ 
+-public class CraftLlama extends CraftChestedHorse implements Llama {
++public class CraftLlama extends CraftChestedHorse implements Llama, CraftRangedEntity<EntityLlama> { // Paper
+ 
+     public CraftLlama(CraftServer server, EntityLlama entity) {
+         super(server, entity);
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
+index 4ed89615f..4fa5e84ea 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.craftbukkit.entity;
+ 
++import com.destroystokyo.paper.entity.CraftRangedEntity;
+ import net.minecraft.server.EntitySkeletonAbstract;
+ 
+ import org.bukkit.craftbukkit.CraftServer;
+ import org.bukkit.entity.EntityType;
+ import org.bukkit.entity.Skeleton;
+ 
+-public class CraftSkeleton extends CraftMonster implements Skeleton {
++public class CraftSkeleton extends CraftMonster implements Skeleton, CraftRangedEntity<EntitySkeletonAbstract> { // Paper
+ 
+     public CraftSkeleton(CraftServer server, EntitySkeletonAbstract entity) {
+         super(server, entity);
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
+index 0349f0a57..2e3d8fcdf 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.craftbukkit.entity;
+ 
++import com.destroystokyo.paper.entity.CraftRangedEntity;
+ import net.minecraft.server.EntitySnowman;
+ import org.bukkit.craftbukkit.CraftServer;
+ import org.bukkit.entity.EntityType;
+ import org.bukkit.entity.Snowman;
+ 
+-public class CraftSnowman extends CraftGolem implements Snowman {
++public class CraftSnowman extends CraftGolem implements Snowman, CraftRangedEntity<EntitySnowman> { // Paper
+     public CraftSnowman(CraftServer server, EntitySnowman entity) {
+         super(server, entity);
+     }
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java
+index c08833cb7..f25998eb6 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.craftbukkit.entity;
+ 
++import com.destroystokyo.paper.entity.CraftRangedEntity;
+ import net.minecraft.server.EntityWitch;
+ import org.bukkit.craftbukkit.CraftServer;
+ import org.bukkit.entity.Witch;
+ import org.bukkit.entity.EntityType;
+ 
+-public class CraftWitch extends CraftMonster implements Witch {
++public class CraftWitch extends CraftMonster implements Witch, CraftRangedEntity<EntityWitch> { // Paper
+     public CraftWitch(CraftServer server, EntityWitch entity) {
+         super(server, entity);
+     }
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
+index fad3db8af..b9bb3a0d1 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
+@@ -0,0 +0,0 @@
+ package org.bukkit.craftbukkit.entity;
+ 
++import com.destroystokyo.paper.entity.CraftRangedEntity;
+ import net.minecraft.server.EntityWither;
+ import org.bukkit.craftbukkit.CraftServer;
+ import org.bukkit.entity.Wither;
+ import org.bukkit.entity.EntityType;
+ 
+-public class CraftWither extends CraftMonster implements Wither {
++public class CraftWither extends CraftMonster implements Wither, CraftRangedEntity<EntityWither> { // Paper
+     public CraftWither(CraftServer server, EntityWither entity) {
+         super(server, entity);
+     }
+--
\ No newline at end of file
diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh
index 8b90e0aeed..a968ade095 100755
--- a/scripts/importmcdev.sh
+++ b/scripts/importmcdev.sh
@@ -80,6 +80,7 @@ import IHopper
 import ItemBlock
 import ItemFireworks
 import ItemMonsterEgg
+import IRangedEntity
 import LegacyPingHandler
 import LotoSelectorEntry
 import NavigationAbstract