13
0
geforkt von Mirrors/Paper
Paper/patches/server/0783-Allow-to-change-the-podium-for-the-EnderDragon.patch

152 Zeilen
10 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Doc <nachito94@msn.com>
Date: Sun, 3 Apr 2022 11:31:42 -0400
Subject: [PATCH] Allow to change the podium for the EnderDragon
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
index 1621a06eff438eccdbc04a2abebd718567c320b3..ccc68b1a1b1b087c52d91591ba4c63b075bfdc66 100644
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java
@@ -103,6 +103,10 @@ public class EnderDragon extends Mob implements Enemy {
2023-06-08 10:47:19 +02:00
private final int[] nodeAdjacency;
private final BinaryHeap openSet;
private final Explosion explosionSource; // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
+ // Paper start - add var for save custom podium
+ @Nullable
+ private BlockPos podium;
+ // Paper end
public EnderDragon(EntityType<? extends EnderDragon> entitytypes, Level world) {
super(EntityType.ENDER_DRAGON, world);
@@ -143,6 +147,19 @@ public class EnderDragon extends Mob implements Enemy {
return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0D);
}
+ // Paper start
+ public BlockPos getPodium() {
+ if (this.podium == null) {
2023-06-08 22:56:13 +02:00
+ return EndPodiumFeature.getLocation(this.getFightOrigin());
+ }
+ return this.podium;
+ }
+
+ public void setPodium(@Nullable BlockPos blockPos) {
+ this.podium = blockPos;
+ }
+ // Paper end
+
@Override
public boolean isFlapping() {
float f = Mth.cos(this.flapTime * 6.2831855F);
@@ -993,7 +1010,7 @@ public class EnderDragon extends Mob implements Enemy {
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));
+ BlockPos blockposition = this.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.getPodium()); // Paper - use custom podium
double d1 = Math.max(Math.sqrt(blockposition.distToCenterSqr(this.position())) / 4.0D, 1.0D);
d0 = (double) segmentOffset / d1;
@@ -1020,7 +1037,7 @@ public class EnderDragon extends Mob implements Enemy {
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));
+ BlockPos blockposition = this.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.getPodium()); // Paper - use custom podium
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
2023-09-22 19:31:02 +02:00
index 247cf0684c1b80a44ad021dcbd35ffc507232ccf..b9ed29f8ee130d513d832784ec824282c790c16c 100644
--- 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
@@ -32,7 +32,7 @@ public class DragonDeathPhase extends AbstractDragonPhaseInstance {
public void doServerTick() {
++this.time;
if (this.targetLocation == null) {
2023-06-08 10:47:19 +02:00
- BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, this.dragon.getPodium()); // Paper - use custom podium
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
2023-09-22 19:31:02 +02:00
index 72ba595bd538a23499449b7de655190a10ef1f5f..4ab60d13beeb4e88bfc7e2b5638672835e225361 100644
--- 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 {
private void findNewTarget() {
if (this.currentPath != null && this.currentPath.isDone()) {
2023-06-08 10:47:19 +02:00
- BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, new BlockPos(EndPodiumFeature.getLocation(this.dragon.getFightOrigin())));
+ BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - use custom podium
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
2023-09-22 19:31:02 +02:00
index 2e8c922b96d7bc3a5d58702f3c7634ac9589977d..2cdd74b052948d8457e4eb5cd35fa8280bc039bb 100644
--- 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
@@ -52,7 +52,7 @@ public class DragonLandingApproachPhase extends AbstractDragonPhaseInstance {
private void findNewTarget() {
if (this.currentPath == null || this.currentPath.isDone()) {
int i = this.dragon.findClosestNode();
2023-06-08 10:47:19 +02:00
- BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - use custom podium
Player player = this.dragon.level().getNearestPlayer(NEAR_EGG_TARGETING, this.dragon, (double)blockPos.getX(), (double)blockPos.getY(), (double)blockPos.getZ());
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
2023-09-22 19:31:02 +02:00
index 9dfa807e0288a95636fd44214625d64cc49e5e76..b97b33b4b146e6925a24c199ec54fa3f8a8ac0ec 100644
--- 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
@@ -39,7 +39,7 @@ public class DragonLandingPhase extends AbstractDragonPhaseInstance {
@Override
public void doServerTick() {
if (this.targetLocation == null) {
2023-06-08 10:47:19 +02:00
- this.targetLocation = Vec3.atBottomCenterOf(this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin())));
+ this.targetLocation = Vec3.atBottomCenterOf(this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium())); // Paper - use custom podium
}
if (this.targetLocation.distanceToSqr(this.dragon.getX(), this.dragon.getY(), this.dragon.getZ()) < 1.0D) {
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
2023-09-22 19:31:02 +02:00
index bbf85d7d30ea4f2f934a45343cead94aadbc0b70..c981fece56bdd17f0b8799994c6f5f9e9a1fc60e 100644
--- 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
@@ -24,7 +24,7 @@ public class DragonTakeoffPhase extends AbstractDragonPhaseInstance {
@Override
public void doServerTick() {
if (!this.firstTick && this.currentPath != null) {
2023-06-08 10:47:19 +02:00
- BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, EndPodiumFeature.getLocation(this.dragon.getFightOrigin()));
+ BlockPos blockPos = this.dragon.level().getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, this.dragon.getPodium()); // Paper - use custom podium
if (!blockPos.closerToCenterThan(this.dragon.position(), 10.0D)) {
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
index 1cfba7aaa807f70ce6d88bf67c7ddacecf55d295..492fdc855fe9735b614b6831aa5baaa6b252cfb6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragon.java
@@ -73,4 +73,22 @@ public class CraftEnderDragon extends CraftMob implements EnderDragon, CraftEnem
public int getDeathAnimationTicks() {
return this.getHandle().dragonDeathTime;
}
+
+ // Paper start
+ @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));
+ }
+ }
+ // Paper end
}