Skip to content

Commit 3d1f58a

Browse files
Fix #10323: Inefficient Ender Dragon respawn sequence
This issue likely arose from the method findExitPortal(), which has been optimized. This optimization will ensure better server performance during the respawn sequence and smoother gameplay. Signed-off-by: Afonso Jacinto <[email protected]>
1 parent 9b1798d commit 3d1f58a

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,76 @@
3737
this.dragonUUID = null;
3838
}
3939
}
40+
@@ -268,21 +_,40 @@
41+
return false;
42+
}
43+
44+
+ // Paper start - Fix inefficient Ender Dragon respawn sequence
45+
@Nullable
46+
public BlockPattern.BlockPatternMatch findExitPortal() {
47+
+
48+
+ BlockPos location = EndPodiumFeature.getLocation(this.origin);
49+
+ LevelChunk chunk = this.level.getChunk(location.getX(), location.getZ());
50+
+
51+
+
52+
+ for (BlockEntity blockEntity : chunk.getBlockEntities().values()) {
53+
+ if (blockEntity instanceof TheEndPortalBlockEntity) {
54+
+ BlockPattern.BlockPatternMatch blockPatternMatch1 = this.exitPortalPattern.find(this.level, blockEntity.getBlockPos());
55+
+ if (blockPatternMatch1 != null) {
56+
+ if (this.portalLocation == null) {
57+
+ this.portalLocation = blockPatternMatch1.getBlock(3, 3, 3).getPos();
58+
+ }
59+
+
60+
+ return blockPatternMatch1;
61+
+ }
62+
+ }
63+
+
64+
+ }
65+
+
66+
ChunkPos chunkPos = new ChunkPos(this.origin);
67+
68+
- for (int i = -8 + chunkPos.x; i <= 8 + chunkPos.x; i++) {
69+
- for (int i1 = -8 + chunkPos.z; i1 <= 8 + chunkPos.z; i1++) {
70+
- LevelChunk chunk = this.level.getChunk(i, i1);
71+
+ for (int i = -8 + chunkPos.x; i <= 8 + chunkPos.x; i+=16) {
72+
+ for (int i1 = -8 + chunkPos.z; i1 <= 8 + chunkPos.z; i1+=16) {
73+
+ chunk = this.level.getChunk(i, i1);
74+
75+
for (BlockEntity blockEntity : chunk.getBlockEntities().values()) {
76+
if (blockEntity instanceof TheEndPortalBlockEntity) {
77+
BlockPattern.BlockPatternMatch blockPatternMatch = this.exitPortalPattern.find(this.level, blockEntity.getBlockPos());
78+
if (blockPatternMatch != null) {
79+
- BlockPos pos = blockPatternMatch.getBlock(3, 3, 3).getPos();
80+
if (this.portalLocation == null) {
81+
- this.portalLocation = pos;
82+
+ this.portalLocation = blockPatternMatch.getBlock(3, 3, 3).getPos();
83+
}
84+
85+
return blockPatternMatch;
86+
@@ -292,22 +_,9 @@
87+
}
88+
}
89+
90+
- BlockPos location = EndPodiumFeature.getLocation(this.origin);
91+
- int i1 = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, location).getY();
92+
-
93+
- for (int i2 = i1; i2 >= this.level.getMinY(); i2--) {
94+
- BlockPattern.BlockPatternMatch blockPatternMatch1 = this.exitPortalPattern.find(this.level, new BlockPos(location.getX(), i2, location.getZ()));
95+
- if (blockPatternMatch1 != null) {
96+
- if (this.portalLocation == null) {
97+
- this.portalLocation = blockPatternMatch1.getBlock(3, 3, 3).getPos();
98+
- }
99+
-
100+
- return blockPatternMatch1;
101+
- }
102+
- }
103+
-
104+
return null;
105+
}
106+
+ // Paper end - Fix inefficient Ender Dragon respawn sequence
107+
108+
private boolean isArenaLoaded() {
109+
if (this.skipArenaLoadedCheck) {
40110
@@ -366,12 +_,22 @@
41111
this.dragonEvent.setVisible(false);
42112
this.spawnExitPortal(true);

0 commit comments

Comments
 (0)