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
2024-10-23 22:52:43 +02:00
index 25d2226c2a5dda411a9e35f7a0e3ab183110c227..38456d3901e495e4c401cff0de7ae38544c1b2a7 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
2024-07-18 10:13:20 +02: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);
2024-10-23 22:52:43 +02:00
@@ -143,6 +147,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);
2024-10-23 22:52:43 +02:00
@@ -988,7 +1005,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-10-23 22:52:43 +02:00
index a897c994423d7d624df6ff3a67789cc2436f0417..29f4acc2943ce009088c61bb32aed330f6e2c051 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-10-23 22:52:43 +02:00
@@ -42,7 +42,7 @@ public class DragonDeathPhase extends AbstractDragonPhaseInstance {
public void doServerTick(ServerLevel world) {
this.time++;
2022-04-07 10:31:30 +02:00
if (this.targetLocation == null) {
2024-10-23 22:52:43 +02:00
- BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ BlockPos blockPos = world.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-10-25 20:09:45 +02:00
index 2db996f3528c65f5d719cbcfb8ae587ff59c14c1..8e39cf181993ff284a2b0429577de0c307f3ef16 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
2024-10-23 22:52:43 +02:00
@@ -53,7 +53,7 @@ public class DragonHoldingPatternPhase extends AbstractDragonPhaseInstance {
private void findNewTarget(ServerLevel world) {
2022-04-07 10:31:30 +02:00
if (this.currentPath != null && this.currentPath.isDone()) {
2024-10-23 22:52:43 +02:00
- BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
2024-10-25 20:09:45 +02:00
+ BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, 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-10-23 22:52:43 +02:00
index 4c28d3c3d601b5316d79c8474d106800abc8e95b..1c4250cc61b770707ad25c0e93caeacbcb0a80b0 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-10-23 22:52:43 +02:00
@@ -52,7 +52,7 @@ public class DragonLandingApproachPhase extends AbstractDragonPhaseInstance {
private void findNewTarget(ServerLevel world) {
if (this.currentPath == null || this.currentPath.isDone()) {
2022-04-07 10:31:30 +02:00
int i = this.dragon.findClosestNode();
2024-10-23 22:52:43 +02:00
- BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - Allow changing the EnderDragon podium
Player player = world.getNearestPlayer(NEAR_EGG_TARGETING, this.dragon, (double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ());
int j;
if (player != null) {
2022-04-07 10:31:30 +02:00
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-10-23 22:52:43 +02:00
index 789df0e05d0cf0df0f66bffc98f587a31770ebea..cfcd3f91517832d26c1177c3715cfa8ebe675193 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-10-23 22:52:43 +02:00
@@ -42,7 +42,7 @@ public class DragonLandingPhase extends AbstractDragonPhaseInstance {
public void doServerTick(ServerLevel world) {
2022-04-07 10:31:30 +02:00
if (this.targetLocation == null) {
2024-04-12 21:14:06 +02:00
this.targetLocation = Vec3.atBottomCenterOf(
2024-10-23 22:52:43 +02:00
- world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()))
+ world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()) // Paper - Allow changing the EnderDragon podium
2024-04-12 21:14:06 +02:00
);
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-10-23 22:52:43 +02:00
index f942ea2ad87d4ae12921578f7b869f064c8db7b0..5c5b03f612621ec4efd92b78601032b84e6f3c28 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-10-23 22:52:43 +02:00
@@ -24,7 +24,7 @@ public class DragonTakeoffPhase extends AbstractDragonPhaseInstance {
@Override
public void doServerTick(ServerLevel world) {
2022-04-07 10:31:30 +02:00
if (!this.firstTick && this.currentPath != null) {
2024-10-23 22:52:43 +02:00
- BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ BlockPos blockPos = world.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - Allow changing the EnderDragon podium
2024-04-12 21:14:06 +02:00
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
}