2022-04-07 10:31:30 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Doc <nachito94@msn.com>
Date: Sun, 3 Apr 2022 11:31:42 -0400
2024-01-18 18:52:00 +01:00
Subject: [PATCH] Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
index 6d01175ea2092bc5f5ebb7aa066450bfec2443a1..61e4f8be9f5927b65ae03da98250d3cd4c1e8c13 100644
2022-04-07 10:31:30 +02:00
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -104,6 +104,10 @@ public class EnderDragon extends Mob implements Enemy {
2023-06-08 10:47:19 +02:00
private final int[] nodeAdjacency;
private final BinaryHeap openSet;
2023-03-14 21:55:49 +01:00
private final Explosion explosionSource; // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
2024-01-18 18:52:00 +01:00
+ // Paper start - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
+ @Nullable
+ private BlockPos podium;
2024-01-18 18:52:00 +01:00
+ // Paper end - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
public EnderDragon(EntityType<? extends EnderDragon> entitytypes, Level world) {
super(EntityType.ENDER_DRAGON, world);
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -144,6 +148,19 @@ public class EnderDragon extends Mob implements Enemy {
2022-04-07 10:31:30 +02:00
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0D);
}
2024-01-18 18:52:00 +01:00
+ // Paper start - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
+ public BlockPos getPodium() {
+ if (this.podium == null) {
2023-06-08 22:56:13 +02:00
+ return EndPodiumFeature.getLocation(this.getFightOrigin());
2022-04-07 10:31:30 +02:00
+ }
+ return this.podium;
+ }
+
+ public void setPodium(@Nullable BlockPos blockPos) {
+ this.podium = blockPos;
+ }
2024-01-18 18:52:00 +01:00
+ // Paper end - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
+
@Override
public boolean isFlapping() {
float f = Mth.cos(this.flapTime * 6.2831855F);
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -995,7 +1012,7 @@ public class EnderDragon extends Mob implements Enemy {
2022-04-07 10:31:30 +02:00
d0 = segment2[1] - segment1[1];
}
} else {
2023-06-08 10:47:19 +02:00
- BlockPos blockposition = this.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.fightOrigin));
2024-01-18 18:52:00 +01:00
+ BlockPos blockposition = this.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.getPodium()); // Paper - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
double d1 = Math.max(Math.sqrt(blockposition.distToCenterSqr(this.position())) / 4.0D, 1.0D);
d0 = (double) segmentOffset / d1;
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#10277)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
9a80d38c SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-722: Add EntityRemoveEvent
258086d9 SPIGOT-7417, PR-967: Add Sign#getTargetSide and Sign#getAllowedEditor
ffaba051 SPIGOT-7584: Add missing Tag.ITEMS_NON_FLAMMABLE_WOOD
CraftBukkit Changes:
98b6c1ac7 SPIGOT-7589 Fix NullPointerException when bans expire
a2736ddb0 SPIGOT-336, SPIGOT-3366, SPIGOT-5768, SPIGOT-6409, SPIGOT-6861, PR-1008: Add EntityRemoveEvent
5bf12cb89 SPIGOT-7565: Throw a more descriptive error message when a developer tries to spawn an entity from a CraftBukkit class
76d95fe7e SPIGOT-7417, PR-1343: Add Sign#getTargetSide and Sign#getAllowedEditor
Spigot Changes:
e9ec5485 Rebuild patches
f1b62e0c Rebuild patches
2024-02-23 14:37:33 +01:00
@@ -1022,7 +1039,7 @@ public class EnderDragon extends Mob implements Enemy {
2022-04-07 10:31:30 +02:00
vec3d = this.getViewVector(tickDelta);
}
} else {
2023-06-08 10:47:19 +02:00
- BlockPos blockposition = this.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.fightOrigin));
2024-01-18 18:52:00 +01:00
+ BlockPos blockposition = this.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.getPodium()); // Paper - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
f1 = Math.max((float) Math.sqrt(blockposition.distToCenterSqr(this.position())) / 4.0F, 1.0F);
float f3 = 6.0F / f1;
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
2024-04-12 21:14:06 +02:00
index 060e2da81c7e55a43412c47e857f91fefd88495b..8e5249e96ffb80b933616913f764e704b670a8b8 100644
2022-04-07 10:31:30 +02:00
--- 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
2024-04-12 21:14:06 +02:00
@@ -35,7 +35,7 @@ public class DragonDeathPhase extends AbstractDragonPhaseInstance {
2022-04-07 10:31:30 +02:00
if (this.targetLocation == null) {
2024-04-12 21:14:06 +02:00
BlockPos blockPos = this.dragon
.level()
- .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, this.dragon.getPodium()); // Paper - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
this.targetLocation = Vec3.atBottomCenterOf(blockPos);
}
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
2024-04-12 21:14:06 +02:00
index 90684c6bfa4025aae0abf098f44e0557c62a0760..422bf66055391b0bb58e3a68156744df8bbfecdb 100644
2022-04-07 10:31:30 +02:00
--- 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
2022-12-07 22:35:34 +01:00
@@ -54,7 +54,7 @@ public class DragonHoldingPatternPhase extends AbstractDragonPhaseInstance {
2022-04-07 10:31:30 +02:00
if (this.currentPath != null && this.currentPath.isDone()) {
2024-04-12 21:14:06 +02:00
BlockPos blockPos = this.dragon
.level()
- .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, new BlockPos(EndPodiumFeature.getLocation(this.dragon.getFightOrigin())));
+ .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, new BlockPos(this.dragon.getPodium())); // Paper - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
int i = this.dragon.getDragonFight() == null ? 0 : this.dragon.getDragonFight().getCrystalsAlive();
if (this.dragon.getRandom().nextInt(i + 3) == 0) {
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.LANDING_APPROACH);
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
2024-04-12 21:14:06 +02:00
index fd36333fc21696e0ec7760cb4702dd7ac5a1a0fb..0832f7103e9b94c65c7856e942c15f8bcdb2ad7f 100644
2022-04-07 10:31:30 +02:00
--- 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
2024-04-12 21:14:06 +02:00
@@ -53,7 +53,7 @@ public class DragonLandingApproachPhase extends AbstractDragonPhaseInstance {
2022-04-07 10:31:30 +02:00
int i = this.dragon.findClosestNode();
2024-04-12 21:14:06 +02:00
BlockPos blockPos = this.dragon
.level()
- .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - Allow changing the EnderDragon podium
Player player = this.dragon.level().getNearestPlayer(NEAR_EGG_TARGETING, this.dragon, blockPos.getX(), blockPos.getY(), blockPos.getZ());
2022-04-07 10:31:30 +02:00
int j;
if (player != null) {
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
2024-04-12 21:14:06 +02:00
index d913147d692e7e58bec4fac44c7e93a1822e8f65..3b960060f152d0352c2f8cdc1c71543cd7fa0dbd 100644
2022-04-07 10:31:30 +02:00
--- 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
2024-04-12 21:14:06 +02:00
@@ -41,7 +41,7 @@ public class DragonLandingPhase extends AbstractDragonPhaseInstance {
2022-04-07 10:31:30 +02:00
public void doServerTick() {
if (this.targetLocation == null) {
2024-04-12 21:14:06 +02:00
this.targetLocation = Vec3.atBottomCenterOf(
- this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()))
+ this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()) // Paper - Allow changing the EnderDragon podium
);
2022-04-07 10:31:30 +02:00
}
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
2024-04-12 21:14:06 +02:00
index b4789d22590d094d76e68e60c022366cba0b7bf6..2e0af7c7f7a98a19f7736c5c9dc7c313c3ca4406 100644
2022-04-07 10:31:30 +02:00
--- 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
2024-04-12 21:14:06 +02:00
@@ -25,7 +25,7 @@ public class DragonTakeoffPhase extends AbstractDragonPhaseInstance {
2022-04-07 10:31:30 +02:00
if (!this.firstTick && this.currentPath != null) {
2024-04-12 21:14:06 +02:00
BlockPos blockPos = this.dragon
.level()
- .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ .getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - Allow changing the EnderDragon podium
if (!blockPos.closerToCenterThan(this.dragon.position(), 10.0)) {
2022-04-07 10:31:30 +02:00
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
2024-01-18 18:52:00 +01:00
index 25b3d889a1742c347e60725df8d6f6c1cee264c7..7b7b89e67d53ed70efae714192c5fa32977f3d9c 100644
2022-04-07 10:31:30 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
2023-08-14 01:32:51 +02:00
@@ -73,4 +73,22 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem
2022-04-07 10:31:30 +02:00
public int getDeathAnimationTicks() {
return this.getHandle().dragonDeathTime;
}
+
2024-01-18 18:52:00 +01:00
+ // Paper start - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
+ @Override
+ public org.bukkit.Location getPodium() {
+ net.minecraft.core.BlockPos blockPosOrigin = this.getHandle().getPodium();
+ return new org.bukkit.Location(getWorld(), blockPosOrigin.getX(), blockPosOrigin.getY(), blockPosOrigin.getZ());
+ }
+
+ @Override
+ public void setPodium(org.bukkit.Location location) {
+ if (location == null) {
+ this.getHandle().setPodium(null);
+ } else {
+ 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");
2023-03-15 00:10:18 +01:00
+ this.getHandle().setPodium(io.papermc.paper.util.MCUtil.toBlockPos(location));
2022-04-07 10:31:30 +02:00
+ }
+ }
2024-01-18 18:52:00 +01:00
+ // Paper end - Allow changing the EnderDragon podium
2022-04-07 10:31:30 +02:00
}