use of net.minecraft.server.world.ChunkHolder in project dynmap by webbukkit.
the class DynmapPlugin method registerEvents.
private void registerEvents() {
// To trigger rendering.
onblockchange = core.isTrigger("blockupdate");
onchunkpopulate = core.isTrigger("chunkpopulate");
onchunkgenerate = core.isTrigger("chunkgenerate");
onblockchange_with_id = core.isTrigger("blockupdate-with-id");
if (onblockchange_with_id)
onblockchange = true;
if ((worldTracker == null) && (onblockchange || onchunkpopulate || onchunkgenerate)) {
worldTracker = new WorldTracker();
ServerWorldEvents.LOAD.register((server, world) -> worldTracker.handleWorldLoad(server, world));
ServerWorldEvents.UNLOAD.register((server, world) -> worldTracker.handleWorldUnload(server, world));
ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> worldTracker.handleChunkLoad(world, chunk));
ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> worldTracker.handleChunkUnload(world, chunk));
ChunkDataEvents.SAVE.register((world, chunk) -> worldTracker.handleChunkDataSave(world, chunk));
BlockEvents.EVENT.register((world, pos) -> worldTracker.handleBlockEvent(world, pos));
}
// Prime the known full chunks
if (onchunkgenerate && (server.getWorlds() != null)) {
for (ServerWorld world : server.getWorlds()) {
FabricWorld fw = getWorld(world);
if (fw == null)
continue;
Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = ((ThreadedAnvilChunkStorageAccessor) world.getChunkManager().threadedAnvilChunkStorage).getChunkHolders();
for (Map.Entry<Long, ChunkHolder> k : chunks.long2ObjectEntrySet()) {
long key = k.getKey();
ChunkHolder ch = k.getValue();
Chunk c = null;
try {
c = ch.getSavingFuture().getNow(null);
} catch (Exception x) {
}
if (c == null)
continue;
ChunkStatus cs = c.getStatus();
ChunkPos pos = ch.getPos();
if (cs == ChunkStatus.FULL) {
// Cooked?
// Add it as known
addKnownChunk(fw, pos);
}
}
}
}
}
use of net.minecraft.server.world.ChunkHolder in project dynmap by webbukkit.
the class DynmapPlugin method registerEvents.
private void registerEvents() {
// To trigger rendering.
onblockchange = core.isTrigger("blockupdate");
onchunkpopulate = core.isTrigger("chunkpopulate");
onchunkgenerate = core.isTrigger("chunkgenerate");
onblockchange_with_id = core.isTrigger("blockupdate-with-id");
if (onblockchange_with_id)
onblockchange = true;
if ((worldTracker == null) && (onblockchange || onchunkpopulate || onchunkgenerate)) {
worldTracker = new WorldTracker();
ServerWorldEvents.LOAD.register((server, world) -> worldTracker.handleWorldLoad(server, world));
ServerWorldEvents.UNLOAD.register((server, world) -> worldTracker.handleWorldUnload(server, world));
ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> worldTracker.handleChunkLoad(world, chunk));
ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> worldTracker.handleChunkUnload(world, chunk));
ChunkDataEvents.SAVE.register((world, chunk) -> worldTracker.handleChunkDataSave(world, chunk));
BlockEvents.EVENT.register((world, pos) -> worldTracker.handleBlockEvent(world, pos));
}
// Prime the known full chunks
if (onchunkgenerate && (server.getWorlds() != null)) {
for (ServerWorld world : server.getWorlds()) {
FabricWorld fw = getWorld(world);
if (fw == null)
continue;
Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = ((ThreadedAnvilChunkStorageAccessor) world.getChunkManager().threadedAnvilChunkStorage).getChunkHolders();
for (Map.Entry<Long, ChunkHolder> k : chunks.long2ObjectEntrySet()) {
long key = k.getKey();
ChunkHolder ch = k.getValue();
Chunk c = null;
try {
c = ch.getFuture().getNow(null);
} catch (Exception x) {
}
if (c == null)
continue;
ChunkStatus cs = c.getStatus();
ChunkPos pos = ch.getPos();
if (cs == ChunkStatus.FULL) {
// Cooked?
// Add it as known
addKnownChunk(fw, pos);
}
}
}
}
}
use of net.minecraft.server.world.ChunkHolder in project dynmap by webbukkit.
the class DynmapPlugin method registerEvents.
private void registerEvents() {
// To trigger rendering.
onblockchange = core.isTrigger("blockupdate");
onchunkpopulate = core.isTrigger("chunkpopulate");
onchunkgenerate = core.isTrigger("chunkgenerate");
onblockchange_with_id = core.isTrigger("blockupdate-with-id");
if (onblockchange_with_id)
onblockchange = true;
if ((worldTracker == null) && (onblockchange || onchunkpopulate || onchunkgenerate)) {
worldTracker = new WorldTracker();
ServerWorldEvents.LOAD.register((server, world) -> worldTracker.handleWorldLoad(server, world));
ServerWorldEvents.UNLOAD.register((server, world) -> worldTracker.handleWorldUnload(server, world));
ServerChunkEvents.CHUNK_LOAD.register((world, chunk) -> worldTracker.handleChunkLoad(world, chunk));
ServerChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> worldTracker.handleChunkUnload(world, chunk));
ChunkDataEvents.SAVE.register((world, chunk) -> worldTracker.handleChunkDataSave(world, chunk));
BlockEvents.EVENT.register((world, pos) -> worldTracker.handleBlockEvent(world, pos));
}
// Prime the known full chunks
if (onchunkgenerate && (server.getWorlds() != null)) {
for (ServerWorld world : server.getWorlds()) {
FabricWorld fw = getWorld(world);
if (fw == null)
continue;
Long2ObjectLinkedOpenHashMap<ChunkHolder> chunks = ((ThreadedAnvilChunkStorageAccessor) world.getChunkManager().threadedAnvilChunkStorage).getChunkHolders();
for (Map.Entry<Long, ChunkHolder> k : chunks.long2ObjectEntrySet()) {
long key = k.getKey();
ChunkHolder ch = k.getValue();
Chunk c = null;
try {
c = ch.getFuture().getNow(null);
} catch (Exception x) {
}
if (c == null)
continue;
ChunkStatus cs = c.getStatus();
ChunkPos pos = ch.getPos();
if (cs == ChunkStatus.FULL) {
// Cooked?
// Add it as known
addKnownChunk(fw, pos);
}
}
}
}
}
use of net.minecraft.server.world.ChunkHolder in project ImmersivePortalsMod by qouteall.
the class ChunkDataSyncManager method sendPacketMultiThreaded.
private void sendPacketMultiThreaded(ServerPlayerEntity player, DimensionalChunkPos chunkPos, IEThreadedAnvilChunkStorage ieStorage) {
ModMain.serverTaskList.addTask(() -> {
ChunkHolder chunkHolder = ieStorage.getChunkHolder_(chunkPos.getChunkPos().toLong());
if (chunkHolder == null) {
// TODO cleanup it
SGlobal.chunkTrackingGraph.setIsLoadedByPortal(chunkPos.dimension, chunkPos.getChunkPos(), true);
return false;
}
CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> future = chunkHolder.createFuture(ChunkStatus.FULL, ((ThreadedAnvilChunkStorage) ieStorage));
future.thenAcceptAsync(either -> {
ModMain.serverTaskList.addTask(() -> {
sendWatchPackets(player, chunkPos, ieStorage);
return true;
});
});
return true;
});
}
use of net.minecraft.server.world.ChunkHolder in project ImmersivePortalsMod by qouteall.
the class MixinEntityTracker method updateCameraPosition_.
@Override
public void updateCameraPosition_(ServerPlayerEntity player) {
IEThreadedAnvilChunkStorage storage = McHelper.getIEStorage(entity.dimension);
if (player != this.entity) {
Vec3d relativePos = (new Vec3d(player.x, player.y, player.z)).subtract(this.entry.method_18759());
int maxWatchDistance = Math.min(this.maxDistance, (storage.getWatchDistance() - 1) * 16);
boolean isWatchedNow = player.dimension == entity.dimension && relativePos.x >= (double) (-maxWatchDistance) && relativePos.x <= (double) maxWatchDistance && relativePos.z >= (double) (-maxWatchDistance) && relativePos.z <= (double) maxWatchDistance && this.entity.canBeSpectated(player);
isWatchedNow = isWatchedNow || SGlobal.chunkTrackingGraph.isPlayerWatchingChunk(player, new DimensionalChunkPos(entity.dimension, new ChunkPos(entity.getBlockPos())));
if (isWatchedNow) {
boolean shouldTrack = this.entity.teleporting;
if (!shouldTrack) {
ChunkPos chunkPos_1 = new ChunkPos(this.entity.chunkX, this.entity.chunkZ);
ChunkHolder chunkHolder_1 = storage.getChunkHolder_(chunkPos_1.toLong());
if (chunkHolder_1 != null && chunkHolder_1.getWorldChunk() != null) {
shouldTrack = true;
}
// else {
// retry it next tick
// ModMain.serverTaskList.addTask(() -> {
// Helper.log("Retry tracking player " + player.getName());
// updateCameraPosition_(player);
// return true;
// });
// }
}
if (shouldTrack && this.playersTracking.add(player)) {
this.entry.startTracking(player);
}
} else if (this.playersTracking.remove(player)) {
this.entry.stopTracking(player);
}
}
}
Aggregations