not that important anyway
This commit is contained in:
parent
729a214e2e
commit
89033b18c5
1 changed files with 0 additions and 39 deletions
|
|
@ -22,43 +22,4 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
@Mod.EventBusSubscriber
|
||||
public class UpdateClimateOnChunkLoadEvent {
|
||||
|
||||
//gleeked out
|
||||
|
||||
// this doesnt work its ass and bad figure a better solution out later
|
||||
|
||||
private static final Map<ChunkPos, ServerLevel> pendingChunks = new ConcurrentHashMap<>();
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onChunkLoad(ChunkEvent.@NotNull Load event) {
|
||||
if (event.isNewChunk() || event.getLevel().isClientSide()) return;
|
||||
|
||||
final ServerLevel level = (ServerLevel) event.getLevel();
|
||||
final ChunkPos pos = event.getChunk().getPos();
|
||||
|
||||
pendingChunks.put(pos, level);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onServerTick(TickEvent.ServerTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.END || pendingChunks.isEmpty()) return;
|
||||
|
||||
Map<ChunkPos, ServerLevel> toProcess = new ConcurrentHashMap<>(pendingChunks);
|
||||
toProcess.keySet().forEach(pendingChunks::remove);
|
||||
|
||||
toProcess.forEach((pos, level) -> {
|
||||
LevelChunk chunk = level.getChunkSource().getChunkNow(pos.x, pos.z);
|
||||
|
||||
if (chunk != null) {
|
||||
try {
|
||||
final ChunkData chunkData = ChunkData.get(chunk);
|
||||
Climate.onChunkLoad(level, new ImposterProtoChunk(chunk, true), chunkData);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error updating climate for chunk " + pos + ": " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue