aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0213-RangedEntity-API.patch
blob: a75f8218f24823d48b4f47173fecc974120c92ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
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 0000000000000000000000000000000000000000..d7a8eb1b8f24ed2741ae9dae62d3f6146f273e1d
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/entity/CraftRangedEntity.java
@@ -0,0 +1,20 @@
+package com.destroystokyo.paper.entity;
+
+import net.minecraft.world.entity.Mob;
+import net.minecraft.world.entity.monster.RangedAttackMob;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
+
+public interface CraftRangedEntity<T extends Mob & RangedAttackMob> extends RangedEntity {
+    T getHandle();
+
+    @Override
+    default void rangedAttack(LivingEntity target, float charge) {
+        getHandle().performRangedAttack(((CraftLivingEntity) target).getHandle(), charge);
+    }
+
+    @Override
+    default void setChargingAttack(boolean raiseHands) {
+        getHandle().setAggressive(raiseHands);
+    }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java
index db6ad6eea8fa6f2755bbb0e1325df8bda98e708a..5ff566186431440c25a26900aba14e4adb642031 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractSkeleton.java
@@ -4,7 +4,7 @@ import org.bukkit.craftbukkit.CraftServer;
 import org.bukkit.entity.AbstractSkeleton;
 import org.bukkit.entity.Skeleton;
 
-public abstract class CraftAbstractSkeleton extends CraftMonster implements AbstractSkeleton {
+public abstract class CraftAbstractSkeleton extends CraftMonster implements AbstractSkeleton, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.AbstractSkeleton> { // Paper
 
     public CraftAbstractSkeleton(CraftServer server, net.minecraft.world.entity.monster.AbstractSkeleton entity) {
         super(server, entity);
@@ -14,4 +14,10 @@ public abstract class CraftAbstractSkeleton extends CraftMonster implements Abst
     public void setSkeletonType(Skeleton.SkeletonType type) {
         throw new UnsupportedOperationException("Not supported.");
     }
+	// Paper start
+    @Override
+    public net.minecraft.world.entity.monster.AbstractSkeleton getHandle() {
+        return (net.minecraft.world.entity.monster.AbstractSkeleton) super.getHandle();
+    }
+    // Paper end
 }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java
index b91d0841b7189d560150d41877e4a0bdea161539..14b575254171f66b8792033c93cf5a325a42b467 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDrowned.java
@@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity;
 import org.bukkit.craftbukkit.CraftServer;
 import org.bukkit.entity.Drowned;
 
-public class CraftDrowned extends CraftZombie implements Drowned {
+public class CraftDrowned extends CraftZombie implements Drowned, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Drowned> { // Paper
 
     public CraftDrowned(CraftServer server, net.minecraft.world.entity.monster.Drowned 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 995c77ee53347328bfd0ad66fcc1b39589967476..5b2af80e584977683cd39e6f440e65a76e929be9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftIllusioner.java
@@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity;
 import org.bukkit.craftbukkit.CraftServer;
 import org.bukkit.entity.Illusioner;
 
-public class CraftIllusioner extends CraftSpellcaster implements Illusioner {
+public class CraftIllusioner extends CraftSpellcaster implements Illusioner, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Illusioner> { // Paper
 
     public CraftIllusioner(CraftServer server, net.minecraft.world.entity.monster.Illusioner 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 dfd4cf1e613b7ccf3ad986f8e0d783593a411194..9986ac517e11b076a29a8c8e3f480ec286fa5825 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
@@ -8,7 +8,7 @@ import org.bukkit.entity.Llama;
 import org.bukkit.entity.Llama.Color;
 import org.bukkit.inventory.LlamaInventory;
 
-public class CraftLlama extends CraftChestedHorse implements Llama {
+public class CraftLlama extends CraftChestedHorse implements Llama, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.animal.horse.Llama> { // Paper
 
     public CraftLlama(CraftServer server, net.minecraft.world.entity.animal.horse.Llama entity) {
         super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
index 2cdcd3a6bd9bd76f2654927d410d22b31199048c..ee69aff7ea348c8b0d2b272451ffd36d39bb0e0e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java
@@ -12,7 +12,7 @@ import org.bukkit.entity.Piglin;
 import org.bukkit.inventory.Inventory;
 import org.bukkit.inventory.ItemType;
 
-public class CraftPiglin extends CraftPiglinAbstract implements Piglin {
+public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.piglin.Piglin> { // Paper
 
     public CraftPiglin(CraftServer server, net.minecraft.world.entity.monster.piglin.Piglin entity) {
         super(server, entity);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java
index d82cea48d9baeaba4dfa32540dcc9ca73651608b..2638c341bc02f201f7ab17fdebcdbdf3a7ec05bf 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPillager.java
@@ -5,7 +5,7 @@ import org.bukkit.craftbukkit.inventory.CraftInventory;
 import org.bukkit.entity.Pillager;
 import org.bukkit.inventory.Inventory;
 
-public class CraftPillager extends CraftIllager implements Pillager {
+public class CraftPillager extends CraftIllager implements Pillager, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Pillager> { // Paper
 
     public CraftPillager(CraftServer server, net.minecraft.world.entity.monster.Pillager 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 cb9efd2fa886d721a802d1c644d9b2c7e6eb948a..5d2e0fb911265f1184de5434464378ffba98d379 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSnowman.java
@@ -4,7 +4,7 @@ import net.minecraft.world.entity.animal.SnowGolem;
 import org.bukkit.craftbukkit.CraftServer;
 import org.bukkit.entity.Snowman;
 
-public class CraftSnowman extends CraftGolem implements Snowman {
+public class CraftSnowman extends CraftGolem implements Snowman, com.destroystokyo.paper.entity.CraftRangedEntity<SnowGolem> { // Paper
     public CraftSnowman(CraftServer server, SnowGolem 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 399b045478d93b2b85b0b25c2dec427dc6a45166..5024a102fe71d7013bc809bb4140763bd4c466e7 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWitch.java
@@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity;
 import org.bukkit.craftbukkit.CraftServer;
 import org.bukkit.entity.Witch;
 
-public class CraftWitch extends CraftRaider implements Witch {
+public class CraftWitch extends CraftRaider implements Witch, com.destroystokyo.paper.entity.CraftRangedEntity<net.minecraft.world.entity.monster.Witch> { // Paper
     public CraftWitch(CraftServer server, net.minecraft.world.entity.monster.Witch 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 2536d59a01e3557678125e26ace9676d7aec6099..83353863e0c58995d3699d5f812d38cae056f695 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java
@@ -9,7 +9,7 @@ import org.bukkit.craftbukkit.boss.CraftBossBar;
 import org.bukkit.entity.LivingEntity;
 import org.bukkit.entity.Wither;
 
-public class CraftWither extends CraftMonster implements Wither {
+public class CraftWither extends CraftMonster implements Wither, com.destroystokyo.paper.entity.CraftRangedEntity<WitherBoss> { // Paper
 
     private BossBar bossBar;