Skip to content

Commit

Permalink
make shifting bedrocking rarer (#55)
Browse files Browse the repository at this point in the history
Signed-off-by: U5B <[email protected]>
  • Loading branch information
U5B authored Mar 22, 2024
1 parent 0edb18c commit 1096e22
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/main/java/com/playmonumenta/structures/StructuresAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ public static CompletableFuture<Void> pasteStructure(@Nonnull BlockArrayClipboar
.checkMemory(false)
.allowedRegionsEverywhere()
.limitUnlimited()
.relightMode(RelightMode.ALL)
.build()) {

/*
Expand Down Expand Up @@ -464,25 +465,11 @@ public static CompletableFuture<Void> pasteStructure(@Nonnull BlockArrayClipboar
copy.setFilterFunction(filterFunction);
copy.setCopyingEntities(includeEntities);
Operations.completeBlindly(copy);

}
MSLog.finer(() -> "Loading structure took " + (System.currentTimeMillis() - pasteTime) + " milliseconds (async)"); // STOP -->

/* Allow the next structure load task to start at this point */
signal.complete(null);

/* Relight affected blocks. Run on main thread as the fixLighting method may or may not be thread-safe. */
Bukkit.getScheduler().runTask(plugin, () -> {
final long lightTime = System.currentTimeMillis(); // <-- START

/* Relight an area 16 blocks bigger than the respawned area */
Region relightRegion = shiftedRegion.clone();
relightRegion.expand(BlockVector3.at(-16, -16, -16), BlockVector3.at(16, 16, 16));

FaweAPI.fixLighting(new BukkitWorld(world), relightRegion, null, RelightMode.ALL);

MSLog.finer(() -> "fixLighting took " + (System.currentTimeMillis() - lightTime) + " milliseconds (main thread)"); // STOP -->
});
/* Add a 5 tick delay until the next task for shifting */
Bukkit.getScheduler().runTaskLater(plugin, () -> signal.complete(null), 5);

/* 6s later, signal caller that loading is complete */
Bukkit.getScheduler().runTaskLater(plugin, () -> future.complete(null), 120);
Expand Down

0 comments on commit 1096e22

Please sign in to comment.