Skip to content

Commit 2914457

Browse files
authored
Allow seting custom podium location for ender dragon (#7695)
1 parent 62dcff3 commit 2914457

File tree

2 files changed

+184
-0
lines changed

2 files changed

+184
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Doc <nachito94@msn.com>
3+
Date: Sat, 2 Apr 2022 23:03:32 -0300
4+
Subject: [PATCH] Allow to change the podium of the EnderDragon
5+
6+
7+
diff --git a/src/main/java/org/bukkit/entity/EnderDragon.java b/src/main/java/org/bukkit/entity/EnderDragon.java
8+
index 856015b08bfa3f18b3df11e25efd079d4a4f7eca..23cbaf886e230d38b3023923f74d1a6c34cd9b9d 100644
9+
--- a/src/main/java/org/bukkit/entity/EnderDragon.java
10+
+++ b/src/main/java/org/bukkit/entity/EnderDragon.java
11+
@@ -104,4 +104,22 @@ public interface EnderDragon extends ComplexLivingEntity, Boss, Mob {
12+
* @return this dragon's death animation ticks
13+
*/
14+
int getDeathAnimationTicks();
15+
+
16+
+ // Paper start
17+
+
18+
+ /**
19+
+ * Get the podium location used by the ender dragon.
20+
+ *
21+
+ * @return the podium location of the dragon
22+
+ */
23+
+ @NotNull
24+
+ org.bukkit.Location getPodium();
25+
+
26+
+ /**
27+
+ * Sets the location of the podium for the ender dragon.
28+
+ *
29+
+ * @param location the location of the podium or null to use the default podium location (exit portal of the end)
30+
+ */
31+
+ void setPodium(@Nullable org.bukkit.Location location);
32+
+ // Paper end
33+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Doc <nachito94@msn.com>
3+
Date: Sun, 3 Apr 2022 11:31:42 -0400
4+
Subject: [PATCH] Allow to change the podium for the EnderDragon
5+
6+
7+
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
8+
index 1eb76c456790b81b657090377dd5ea547898f9a5..8c4db2f0e5158872879da52a96bc592145e52e13 100644
9+
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
10+
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
11+
@@ -100,6 +100,10 @@ public class EnderDragon extends Mob implements Enemy {
12+
private final int[] nodeAdjacency = new int[24];
13+
private final BinaryHeap openSet = new BinaryHeap();
14+
private Explosion explosionSource = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.BlockInteraction.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
15+
+ // Paper start - add var for save custom podium
16+
+ @Nullable
17+
+ private BlockPos podium;
18+
+ // Paper end
19+
20+
public EnderDragon(EntityType<? extends EnderDragon> entitytypes, Level world) {
21+
super(EntityType.ENDER_DRAGON, world);
22+
@@ -120,6 +124,19 @@ public class EnderDragon extends Mob implements Enemy {
23+
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0D);
24+
}
25+
26+
+ // Paper start
27+
+ public BlockPos getPodium() {
28+
+ if (this.podium == null) {
29+
+ return EndPodiumFeature.END_PODIUM_LOCATION;
30+
+ }
31+
+ return this.podium;
32+
+ }
33+
+
34+
+ public void setPodium(@Nullable BlockPos blockPos) {
35+
+ this.podium = blockPos;
36+
+ }
37+
+ // Paper end
38+
+
39+
@Override
40+
public boolean isFlapping() {
41+
float f = Mth.cos(this.flapTime * 6.2831855F);
42+
@@ -947,7 +964,7 @@ public class EnderDragon extends Mob implements Enemy {
43+
d0 = segment2[1] - segment1[1];
44+
}
45+
} else {
46+
- BlockPos blockposition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION);
47+
+ BlockPos blockposition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.getPodium()); // Paper - use custom podium
48+
double d1 = Math.max(Math.sqrt(blockposition.distToCenterSqr(this.position())) / 4.0D, 1.0D);
49+
50+
d0 = (double) segmentOffset / d1;
51+
@@ -974,7 +991,7 @@ public class EnderDragon extends Mob implements Enemy {
52+
vec3d = this.getViewVector(tickDelta);
53+
}
54+
} else {
55+
- BlockPos blockposition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION);
56+
+ BlockPos blockposition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.getPodium()); // Paper - use custom podium
57+
58+
f1 = Math.max((float) Math.sqrt(blockposition.distToCenterSqr(this.position())) / 4.0F, 1.0F);
59+
float f3 = 6.0F / f1;
60+
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java
61+
index a64ee433e34538ce2b52207b6183999ae611e5dd..0f78e1ab090bb1df7b863c90b3c7465a3ce28c8c 100644
62+
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java
63+
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonDeathPhase.java
64+
@@ -32,7 +32,7 @@ public class DragonDeathPhase extends AbstractDragonPhaseInstance {
65+
public void doServerTick() {
66+
++this.time;
67+
if (this.targetLocation == null) {
68+
- BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION);
69+
+ BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, this.dragon.getPodium()); // Paper - use custom podium
70+
this.targetLocation = Vec3.atBottomCenterOf(blockPos);
71+
}
72+
73+
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java
74+
index e58f608e424e384606289d9ff27bf8f9c63aeeb2..4c338d7f3d5274a36db768e4a1cdedca130127d4 100644
75+
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java
76+
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonHoldingPatternPhase.java
77+
@@ -55,7 +55,7 @@ public class DragonHoldingPatternPhase extends AbstractDragonPhaseInstance {
78+
79+
private void findNewTarget() {
80+
if (this.currentPath != null && this.currentPath.isDone()) {
81+
- BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, new BlockPos(EndPodiumFeature.END_PODIUM_LOCATION));
82+
+ BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - use custom podium
83+
int i = this.dragon.getDragonFight() == null ? 0 : this.dragon.getDragonFight().getCrystalsAlive();
84+
if (this.dragon.getRandom().nextInt(i + 3) == 0) {
85+
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.LANDING_APPROACH);
86+
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java
87+
index fdfdd42a30d752b11d18f2cefe84c1e9ddec41a2..5fca7c4e1d1d9da6f29ad70f1b5703c7f092d851 100644
88+
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java
89+
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingApproachPhase.java
90+
@@ -52,7 +52,7 @@ public class DragonLandingApproachPhase extends AbstractDragonPhaseInstance {
91+
private void findNewTarget() {
92+
if (this.currentPath == null || this.currentPath.isDone()) {
93+
int i = this.dragon.findClosestNode();
94+
- BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION);
95+
+ BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - use custom podium
96+
Player player = this.dragon.level.getNearestPlayer(NEAR_EGG_TARGETING, this.dragon, (double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ());
97+
int j;
98+
if (player != null) {
99+
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java
100+
index c3eb04fa31a8e767c737091c2e1a3f858589e16b..1ee3ba970e33e20e5c72bc2f4153889b60c0e77e 100644
101+
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java
102+
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonLandingPhase.java
103+
@@ -39,7 +39,7 @@ public class DragonLandingPhase extends AbstractDragonPhaseInstance {
104+
@Override
105+
public void doServerTick() {
106+
if (this.targetLocation == null) {
107+
- this.targetLocation = Vec3.atBottomCenterOf(this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION));
108+
+ this.targetLocation = Vec3.atBottomCenterOf(this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium())); // Paper - use custom podium
109+
}
110+
111+
if (this.targetLocation.distanceToSqr(this.dragon.getX(), this.dragon.getY(), this.dragon.getZ()) < 1.0D) {
112+
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java
113+
index 0ae65d0fa03d12486f48b0274b6e2d4eea169caf..ffe89d8c1f22f672d145fedb3bb102589dc31656 100644
114+
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java
115+
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonTakeoffPhase.java
116+
@@ -24,7 +24,7 @@ public class DragonTakeoffPhase extends AbstractDragonPhaseInstance {
117+
@Override
118+
public void doServerTick() {
119+
if (!this.firstTick && this.currentPath != null) {
120+
- BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.END_PODIUM_LOCATION);
121+
+ BlockPos blockPos = this.dragon.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - use custom podium
122+
if (!blockPos.closerToCenterThan(this.dragon.position(), 10.0D)) {
123+
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
124+
}
125+
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
126+
index cd487bd68f9a8177ae3e015b3a5d1bc469743f48..eeb6d48da156602c046db891cac0ccb4fa639473 100644
127+
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
128+
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
129+
@@ -79,4 +79,22 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon {
130+
public int getDeathAnimationTicks() {
131+
return this.getHandle().dragonDeathTime;
132+
}
133+
+
134+
+ // Paper start
135+
+ @Override
136+
+ public org.bukkit.Location getPodium() {
137+
+ net.minecraft.core.BlockPos blockPosOrigin = this.getHandle().getPodium();
138+
+ return new org.bukkit.Location(getWorld(), blockPosOrigin.getX(), blockPosOrigin.getY(), blockPosOrigin.getZ());
139+
+ }
140+
+
141+
+ @Override
142+
+ public void setPodium(org.bukkit.Location location) {
143+
+ if (location == null) {
144+
+ this.getHandle().setPodium(null);
145+
+ } else {
146+
+ org.apache.commons.lang.Validate.isTrue(location.getWorld() == null || location.getWorld().equals(getWorld()), "You cannot set a podium in a different world to where the dragon is");
147+
+ this.getHandle().setPodium(new net.minecraft.core.BlockPos(location.getX(), location.getY(), location.getZ()));
148+
+ }
149+
+ }
150+
+ // Paper end
151+
}

0 commit comments

Comments
 (0)