From 7abf2eeeac9bba2a94d1370116ea34b87100b13d Mon Sep 17 00:00:00 2001 From: Aikar 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. --- .../0067-LivingEntity-setKiller.patch | 6 +- .../0119-RangedEntity-API.patch | 134 +++++++++++++++ .../0316-RangedEntity-API.patch | 162 ++++++++++++++++++ scripts/importmcdev.sh | 1 + 4 files changed, 300 insertions(+), 3 deletions(-) create mode 100644 Spigot-API-Patches/0119-RangedEntity-API.patch create mode 100644 Spigot-Server-Patches/0316-RangedEntity-API.patch diff --git a/Spigot-API-Patches/0067-LivingEntity-setKiller.patch b/Spigot-API-Patches/0067-LivingEntity-setKiller.patch index 68405c169..9ac08e8c3 100644 --- a/Spigot-API-Patches/0067-LivingEntity-setKiller.patch +++ b/Spigot-API-Patches/0067-LivingEntity-setKiller.patch @@ -1,11 +1,11 @@ -From 95f344d24cda39523f06b944ee96d0c7c5893d06 Mon Sep 17 00:00:00 2001 +From ac9baf5c2739f255205d959cc519be2db01773da Mon Sep 17 00:00:00 2001 From: BillyGalbreath Date: Mon, 31 Jul 2017 01:49:43 -0500 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 @@ -14,6 +14,8 @@ import org.bukkit.potion.PotionEffect; @@ -34,5 +34,5 @@ index be51e389..4a51c519 100644 * Adds the given {@link PotionEffect} to the living entity. *

-- -2.15.1 +2.18.0 diff --git a/Spigot-API-Patches/0119-RangedEntity-API.patch b/Spigot-API-Patches/0119-RangedEntity-API.patch new file mode 100644 index 000000000..dadfbeb24 --- /dev/null +++ b/Spigot-API-Patches/0119-RangedEntity-API.patch @@ -0,0 +1,134 @@ +From d22cc23fcedf807711836fcaedd9d7fd95f47f2d Mon Sep 17 00:00:00 2001 +From: Aikar +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 +1,19 @@ ++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 +@@ -1,6 +1,10 @@ + 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 +@@ -1,11 +1,12 @@ + 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 +@@ -1,9 +1,11 @@ + 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 +@@ -1,9 +1,11 @@ + 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 +@@ -1,7 +1,9 @@ + 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 +@@ -1,7 +1,9 @@ + 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 + } +-- +2.18.0 + diff --git a/Spigot-Server-Patches/0316-RangedEntity-API.patch b/Spigot-Server-Patches/0316-RangedEntity-API.patch new file mode 100644 index 000000000..a0fa438b0 --- /dev/null +++ b/Spigot-Server-Patches/0316-RangedEntity-API.patch @@ -0,0 +1,162 @@ +From eeefed6577e1b6946c4197d382d605f085e69b8f Mon Sep 17 00:00:00 2001 +From: Aikar +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 +1,19 @@ ++package com.destroystokyo.paper.entity; ++ ++import net.minecraft.server.IRangedEntity; ++import org.bukkit.craftbukkit.entity.CraftLivingEntity; ++import org.bukkit.entity.LivingEntity; ++ ++public interface CraftRangedEntity 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 +@@ -2,7 +2,8 @@ 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 +@@ -1,11 +1,12 @@ + 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 { // 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 +@@ -1,5 +1,6 @@ + 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; +@@ -9,7 +10,7 @@ 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 { // 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 +@@ -1,12 +1,13 @@ + 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 { // 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 +@@ -1,11 +1,12 @@ + 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 { // 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 +@@ -1,11 +1,12 @@ + 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 { // 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 +@@ -1,11 +1,12 @@ + 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 { // Paper + public CraftWither(CraftServer server, EntityWither entity) { + super(server, entity); + } +-- +2.18.0 + diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 8b90e0aee..a968ade09 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