From 3a4a542ee1d8cb96f99529d0ba80f07c9741dadd 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 00000000..696660b0 --- /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 raiseHands) { + getHandle().setChargingAttack(raiseHands); + } +} diff --git a/src/main/java/net/minecraft/server/IRangedEntity.java b/src/main/java/net/minecraft/server/IRangedEntity.java index b4178ce1..9b79ac77 100644 --- a/src/main/java/net/minecraft/server/IRangedEntity.java +++ b/src/main/java/net/minecraft/server/IRangedEntity.java @@ -2,5 +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 - OBFHELPER + + // - see EntitySkeletonAbstract melee goal + void q(boolean flag); default void setChargingAttack(boolean charging) { q(charging); }; // Paper } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java index 6e41dfd9..390183ff 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java @@ -1,11 +1,12 @@ package org.bukkit.craftbukkit.entity; +import com.destroystokyo.paper.entity.CraftRangedEntity; import net.minecraft.server.EntityDrowned; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Drowned; import org.bukkit.entity.EntityType; -public class CraftDrowned extends CraftZombie implements Drowned { +public class CraftDrowned extends CraftZombie implements Drowned, CraftRangedEntity { // Paper public CraftDrowned(CraftServer server, EntityDrowned entity) { super(server, entity); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java index 2ec1af8b..f31d3eed 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 23ab78da..3f94c5a9 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 b4ae8984..02df66ec 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java @@ -1,11 +1,12 @@ 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 27460c59..e482b1c9 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 244e4dc8..bae107e7 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; // Paper import net.minecraft.server.EntityWitch; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.EntityType; import org.bukkit.entity.Witch; -public class CraftWitch extends CraftRaider implements Witch { +public class CraftWitch extends CraftRaider 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 38b555cc..03cf6136 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.entity; +import com.destroystokyo.paper.entity.CraftRangedEntity; import net.minecraft.server.EntityWither; import org.bukkit.boss.BossBar; import org.bukkit.craftbukkit.CraftServer; @@ -7,7 +8,7 @@ import org.bukkit.craftbukkit.boss.CraftBossBar; import org.bukkit.entity.EntityType; import org.bukkit.entity.Wither; -public class CraftWither extends CraftMonster implements Wither { +public class CraftWither extends CraftMonster implements Wither, CraftRangedEntity { // Paper private BossBar bossBar; -- 2.25.1.windows.1