Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
--- a/net/minecraft/world/level/dimension/end/EnderDragonFight.java
+++ b/net/minecraft/world/level/dimension/end/EnderDragonFight.java
@@ -104,6 +_,7 @@
public @Nullable DragonRespawnStage respawnStage;
private int respawnTime;
public List<EntityReference<EndCrystal>> respawnCrystals;
+ public boolean emptyCrystalRespawnAllowed = false; // Paper - Support allowing the dragon to respawn if no crystals are found
public static final Codec<EnderDragonFight> CODEC = RecordCodecBuilder.create(
i -> i.group(
ExtraCodecs.optionalAlwaysPresentFieldOf(Codec.BOOL, "needs_state_scanning", true).forGetter(fight -> fight.needsStateScanning),
@@ -160,6 +_,12 @@
);
this.dragonEvent.setPlayBossMusic(true).setCreateWorldFog(true);
Expand All @@ -13,6 +21,15 @@
if (this.gateways.isEmpty()) {
ObjectArrayList<Integer> newGateways = new ObjectArrayList<>(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers()));
Util.shuffle(newGateways, RandomSource.createThreadLocalInstance(seed));
@@ -199,7 +_,7 @@
.map(e -> e.getEntity(this.level, EndCrystal.class))
.filter(Objects::nonNull)
.toList();
- if (respawnCrystals.isEmpty()) {
+ if (respawnCrystals.isEmpty() && !this.emptyCrystalRespawnAllowed) { // Paper - Support allowing the dragon to respawn if no crystals are found
this.abortRespawnSequence();
return;
}
@@ -246,9 +_,9 @@
this.dragonUUID = dragon.getUUID();
LOGGER.info("Found that there's a dragon still alive ({})", dragon);
Expand All @@ -25,6 +42,14 @@
this.dragonUUID = null;
}
}
@@ -281,6 +_,7 @@
if (stage == DragonRespawnStage.END) {
this.respawnStage = null;
this.dragonKilled = false;
+ this.emptyCrystalRespawnAllowed = false; // Paper - Support allowing the dragon to respawn if no crystals are found
EnderDragon dragon = this.createNewDragon();
if (dragon != null) {
for (ServerPlayer player : this.dragonEvent.getPlayers()) {
@@ -408,12 +_,20 @@
this.dragonEvent.setVisible(false);
this.spawnExitPortal(true);
Expand Down Expand Up @@ -112,6 +137,14 @@
}
}
}
@@ -509,6 +_,7 @@

private void abortRespawnSequence() {
LOGGER.debug("Aborting respawn sequence");
+ this.emptyCrystalRespawnAllowed = false; // Paper - Support allowing the dragon to respawn if no crystals are found
this.respawnStage = null;
this.respawnTime = 0;
this.resetSpikeCrystals();
@@ -520,7 +_,13 @@
return this.hasPreviouslyKilledDragon;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void initiateRespawn() {
}

@Override
public boolean initiateRespawn(Collection<EnderCrystal> crystals) { // todo doesn't seems to work without crystals
public boolean initiateRespawn(Collection<EnderCrystal> crystals) {
if (this.hasBeenPreviouslyKilled() && this.getRespawnPhase() == RespawnPhase.NONE) {
// Copy from EnderDragonFight#tryRespawn for generate exit portal if not exists
Comment thread
Lulu13022002 marked this conversation as resolved.
if (this.handle.exitPortalLocation == null) {
Expand All @@ -94,6 +94,8 @@ public boolean initiateRespawn(Collection<EnderCrystal> crystals) { // todo does
return !((CraftWorld) crystal.getWorld()).getHandle().equals(this.handle.level);
});

this.handle.emptyCrystalRespawnAllowed = filteredCrystals.isEmpty();

return this.handle.respawnDragon(
Lists.transform(filteredCrystals, crystal -> ((CraftEnderCrystal) crystal).getHandle())
);
Expand Down
Loading