-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3f29f4
commit fed9042
Showing
2 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Jake Potrebic <[email protected]> | ||
Date: Sun, 18 Dec 2022 13:40:17 -0800 | ||
Subject: [PATCH] More DragonBattle API | ||
|
||
|
||
diff --git a/src/main/java/org/bukkit/boss/DragonBattle.java b/src/main/java/org/bukkit/boss/DragonBattle.java | ||
index 8c55741cd17130686806c74627e11d464822053e..1d2ca775a243200bbcd4cbd8a750a9fb2628e73c 100644 | ||
--- a/src/main/java/org/bukkit/boss/DragonBattle.java | ||
+++ b/src/main/java/org/bukkit/boss/DragonBattle.java | ||
@@ -134,4 +134,44 @@ public interface DragonBattle { | ||
*/ | ||
NONE; | ||
} | ||
+ // Paper start | ||
+ /** | ||
+ * Gets the number of gateways tracked by this DragonBattle. | ||
+ * This starts out at 0 and will increase to 20, once for each | ||
+ * kill of the {@link EnderDragon}. | ||
+ * | ||
+ * @return the number of gateways around the end island tracked by this | ||
+ */ | ||
+ int getGatewayCount(); | ||
+ | ||
+ /** | ||
+ * Tries to spawn a new end gateway using default game mechanics. | ||
+ * | ||
+ * @return true if successful, false if there is already the maximum. | ||
+ */ | ||
+ boolean spawnNewGateway(); | ||
+ | ||
+ /** | ||
+ * Spawns a new end gateway at the specified position. This will | ||
+ * spawn regardless of the number of gateways already present. | ||
+ * | ||
+ * @param position position for the new gateway | ||
+ */ | ||
+ void spawnNewGateway(@NotNull io.papermc.paper.math.Position position); | ||
+ | ||
+ /** | ||
+ * Gets the {@link org.bukkit.entity.EnderCrystal}s being used to respawn the dragon. If no respawn | ||
+ * is ongoing, the list will be empty. | ||
+ * | ||
+ * @return the respawn crystals | ||
+ */ | ||
+ java.util.@NotNull @org.jetbrains.annotations.Unmodifiable List<org.bukkit.entity.EnderCrystal> getRespawnCrystals(); | ||
+ | ||
+ /** | ||
+ * Gets the {@link org.bukkit.entity.EnderCrystal}s on top of the pillars that heal the dragon. | ||
+ * | ||
+ * @return the healing crystals | ||
+ */ | ||
+ java.util.@NotNull @org.jetbrains.annotations.Unmodifiable List<org.bukkit.entity.EnderCrystal> getHealingCrystals(); | ||
+ // Paper end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Jake Potrebic <[email protected]> | ||
Date: Sun, 18 Dec 2022 13:40:05 -0800 | ||
Subject: [PATCH] More DragonBattle API | ||
|
||
== AT == | ||
public net.minecraft.world.level.dimension.end.EndDragonFight GATEWAY_COUNT | ||
public net.minecraft.world.level.dimension.end.EndDragonFight gateways | ||
public net.minecraft.world.level.dimension.end.EndDragonFight respawnCrystals | ||
public net.minecraft.world.level.dimension.end.EndDragonFight spawnNewGateway(Lnet/minecraft/core/BlockPos;)V | ||
|
||
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java | ||
index c63f05a3d29146bfb8d5c93df5706145e3eaf716..630971d7a87c12798672af9635535eaf80a3ec9c 100644 | ||
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java | ||
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java | ||
@@ -439,6 +439,24 @@ public class EndDragonFight { | ||
this.gateways.clear(); | ||
} | ||
|
||
+ // Paper start | ||
+ public boolean spawnNewGatewayIfPossible() { | ||
+ if (!this.gateways.isEmpty()) { | ||
+ this.spawnNewGateway(); | ||
+ return true; | ||
+ } | ||
+ return false; | ||
+ } | ||
+ | ||
+ public List<EndCrystal> getSpikeCrystals() { | ||
+ final List<EndCrystal> endCrystals = new java.util.ArrayList<>(); | ||
+ for (final SpikeFeature.EndSpike spike : SpikeFeature.getSpikesForLevel(this.level)) { | ||
+ endCrystals.addAll(this.level.getEntitiesOfClass(EndCrystal.class, spike.getTopBoundingBox())); | ||
+ } | ||
+ return endCrystals; | ||
+ } | ||
+ // Paper end | ||
+ | ||
private void spawnNewGateway() { | ||
if (!this.gateways.isEmpty()) { | ||
int i = (Integer) this.gateways.remove(this.gateways.size() - 1); | ||
diff --git a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java | ||
index 9895225593a6b6d22c4c5d3966dd79de1dfa4582..ccc73410ba6938dfdb7c23c2124f9f657b3a7e5d 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/boss/CraftDragonBattle.java | ||
@@ -132,4 +132,46 @@ public class CraftDragonBattle implements DragonBattle { | ||
private DragonRespawnAnimation toNMSRespawnPhase(RespawnPhase phase) { | ||
return (phase != RespawnPhase.NONE) ? DragonRespawnAnimation.values()[phase.ordinal()] : null; | ||
} | ||
+ // Paper start | ||
+ @Override | ||
+ public int getGatewayCount() { | ||
+ return EndDragonFight.GATEWAY_COUNT - this.handle.gateways.size(); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public boolean spawnNewGateway() { | ||
+ return this.handle.spawnNewGatewayIfPossible(); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public void spawnNewGateway(final io.papermc.paper.math.Position position) { | ||
+ this.handle.spawnNewGateway(io.papermc.paper.util.MCUtil.toBlockPos(position)); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public java.util.List<org.bukkit.entity.EnderCrystal> getRespawnCrystals() { | ||
+ if (this.handle.respawnCrystals == null) { | ||
+ return java.util.Collections.emptyList(); | ||
+ } | ||
+ | ||
+ final java.util.List<org.bukkit.entity.EnderCrystal> enderCrystals = new java.util.ArrayList<>(); | ||
+ for (final net.minecraft.world.entity.boss.enderdragon.EndCrystal endCrystal : this.handle.respawnCrystals) { | ||
+ if (!endCrystal.isRemoved() && endCrystal.isAlive() && endCrystal.valid) { | ||
+ enderCrystals.add(((org.bukkit.entity.EnderCrystal) endCrystal.getBukkitEntity())); | ||
+ } | ||
+ } | ||
+ return java.util.Collections.unmodifiableList(enderCrystals); | ||
+ } | ||
+ | ||
+ @Override | ||
+ public java.util.List<org.bukkit.entity.EnderCrystal> getHealingCrystals() { | ||
+ final java.util.List<org.bukkit.entity.EnderCrystal> enderCrystals = new java.util.ArrayList<>(); | ||
+ for (final net.minecraft.world.entity.boss.enderdragon.EndCrystal endCrystal : this.handle.getSpikeCrystals()) { | ||
+ if (!endCrystal.isRemoved() && endCrystal.isAlive() && endCrystal.valid) { | ||
+ enderCrystals.add(((org.bukkit.entity.EnderCrystal) endCrystal.getBukkitEntity())); | ||
+ } | ||
+ } | ||
+ return java.util.Collections.unmodifiableList(enderCrystals); | ||
+ } | ||
+ // Paper end | ||
} |