mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
* init 1.21.4, and boom! * build change, but weight not work * just work * Build changes, and delete timings * Fix API patches (#406) * Fix API patches * merge --------- Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com> * 0006/0129 * 0009/0129 * 0011/0129 * 0018/0129 * 0030/0129 * 0035/0129 * 0043/0129 * 0048/0129 * 0049/0129 * 0057/0129 * 0065/0129 * 0086/0129 (#408) * 0072/0129 * 0080/0129 * Readd patch infos * 0086/0129 * Delete applied patches * 0087/0129 * 0091/0129 * 0097/0129 * 0101/0129 * 102/129 * 0107/0129 * 0112/0129 * 0118/0129 * 0129/0129, 100% patched * fix some * server work * Protocol... (#409) * Jade v7 * Fix changed part for Jade * Formatting imports, add Lms Paster protocol * REI payloads 5/8 * Add REI support, remove unnecessary content in Jade * Rename * Make jade better * Make action work * fix action jar * Fix some protocol * Fix bot action, and entity tickCount * Fix Warden GameEventListener register on load * Fix extra Raider drop * Fix grindstone overstacking * Update Paper, and some doc * Merge * [ci skip] Update Action --------- Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
105 lines
5.7 KiB
Diff
105 lines
5.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
Date: Tue, 27 Jun 2023 13:22:34 +0800
|
|
Subject: [PATCH] Optimized dragon respawn
|
|
|
|
|
|
diff --git a/net/minecraft/world/level/block/state/pattern/BlockPattern.java b/net/minecraft/world/level/block/state/pattern/BlockPattern.java
|
|
index f7bb979f08634a7e1b77c59040f59fb5e11aafa5..3cad7d6bca9af77bace18bfd7cc013ac22be4075 100644
|
|
--- a/net/minecraft/world/level/block/state/pattern/BlockPattern.java
|
|
+++ b/net/minecraft/world/level/block/state/pattern/BlockPattern.java
|
|
@@ -59,7 +59,7 @@ public class BlockPattern {
|
|
}
|
|
|
|
@Nullable
|
|
- private BlockPattern.BlockPatternMatch matches(BlockPos pos, Direction finger, Direction thumb, LoadingCache<BlockPos, BlockInWorld> cache) {
|
|
+ public BlockPattern.BlockPatternMatch matches(BlockPos pos, Direction finger, Direction thumb, LoadingCache<BlockPos, BlockInWorld> cache) { // Leaves - private -> public
|
|
for (int i = 0; i < this.width; i++) {
|
|
for (int i1 = 0; i1 < this.height; i1++) {
|
|
for (int i2 = 0; i2 < this.depth; i2++) {
|
|
diff --git a/net/minecraft/world/level/dimension/end/EndDragonFight.java b/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
index 6e7e87c32734b3aae354bc34459e5f207da5c78f..5a28a821bb401f8f1465b085c9ffda52ba9a0a9f 100644
|
|
--- a/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
+++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java
|
|
@@ -274,8 +274,68 @@ public class EndDragonFight {
|
|
return false;
|
|
}
|
|
|
|
+ // Leaves start - optimizedDragonRespawn
|
|
+ private int cachePortalChunkIteratorX = -8;
|
|
+ private int cachePortalChunkIteratorZ = -8;
|
|
+ private int cachePortalOriginIteratorY = -1;
|
|
+
|
|
@Nullable
|
|
public BlockPattern.BlockPatternMatch findExitPortal() {
|
|
+ if (org.leavesmc.leaves.LeavesConfig.performance.optimizedDragonRespawn) {
|
|
+ int i, j;
|
|
+ for (i = cachePortalChunkIteratorX; i <= 8; ++i) {
|
|
+ for (j = cachePortalChunkIteratorZ; j <= 8; ++j) {
|
|
+ LevelChunk worldChunk = this.level.getChunk(i, j);
|
|
+ for (BlockEntity blockEntity : worldChunk.getBlockEntities().values()) {
|
|
+ if (blockEntity instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity) {
|
|
+ continue;
|
|
+ }
|
|
+ if (blockEntity instanceof TheEndPortalBlockEntity) {
|
|
+ BlockPattern.BlockPatternMatch blockPatternMatch = this.exitPortalPattern.find(this.level, blockEntity.getBlockPos());
|
|
+ if (blockPatternMatch != null) {
|
|
+ BlockPos blockPos = blockPatternMatch.getBlock(3, 3, 3).getPos();
|
|
+ if (this.portalLocation == null) {
|
|
+ this.portalLocation = blockPos;
|
|
+ }
|
|
+ //No need to judge whether optimizing option is open
|
|
+ cachePortalChunkIteratorX = i;
|
|
+ cachePortalChunkIteratorZ = j;
|
|
+ return blockPatternMatch;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (this.needsStateScanning || this.portalLocation == null) {
|
|
+ if (cachePortalOriginIteratorY != -1) {
|
|
+ i = cachePortalOriginIteratorY;
|
|
+ } else {
|
|
+ i = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.getLocation(BlockPos.ZERO)).getY();
|
|
+ }
|
|
+ boolean notFirstSearch = false;
|
|
+ for (j = i; j >= 0; --j) {
|
|
+ BlockPattern.BlockPatternMatch result2 = null;
|
|
+ if (notFirstSearch) {
|
|
+ result2 = org.leavesmc.leaves.util.BlockPatternHelper.partialSearchAround(this.exitPortalPattern, this.level, new BlockPos(EndPodiumFeature.getLocation(BlockPos.ZERO).getY(), j, EndPodiumFeature.getLocation(BlockPos.ZERO).getZ()));
|
|
+ } else {
|
|
+ result2 = this.exitPortalPattern.find(this.level, new BlockPos(EndPodiumFeature.getLocation(BlockPos.ZERO).getX(), j, EndPodiumFeature.getLocation(BlockPos.ZERO).getZ()));
|
|
+ }
|
|
+ if (result2 != null) {
|
|
+ if (this.portalLocation == null) {
|
|
+ this.portalLocation = result2.getBlock(3, 3, 3).getPos();
|
|
+ }
|
|
+ cachePortalOriginIteratorY = j;
|
|
+ return result2;
|
|
+ }
|
|
+ notFirstSearch = true;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return null;
|
|
+ }
|
|
+ // Leaves end - optimizedDragonRespawn
|
|
+
|
|
ChunkPos chunkPos = new ChunkPos(this.origin);
|
|
|
|
for (int i = -8 + chunkPos.x; i <= 8 + chunkPos.x; i++) {
|
|
@@ -571,6 +631,11 @@ public class EndDragonFight {
|
|
}
|
|
|
|
public boolean respawnDragon(List<EndCrystal> crystals) { // CraftBukkit - return boolean
|
|
+ // Leaves - start optimizedDragonRespawn
|
|
+ cachePortalChunkIteratorX = -8;
|
|
+ cachePortalChunkIteratorZ = -8;
|
|
+ cachePortalOriginIteratorY = -1;
|
|
+ // Leaves - end optimizedDragonRespawn
|
|
if (this.dragonKilled && this.respawnStage == null) {
|
|
for (BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); blockPatternMatch != null; blockPatternMatch = this.findExitPortal()) {
|
|
for (int i = 0; i < this.exitPortalPattern.getWidth(); i++) {
|