use of com.qouteall.immersive_portals.ducks.IEThreadedAnvilChunkStorage in project ImmersivePortalsMod by qouteall.
the class ChunkDataSyncManager method onBeginWatch.
/**
* {@link ThreadedAnvilChunkStorage#sendChunkDataPackets(ServerPlayerEntity, Packet[], WorldChunk)}
*/
private void onBeginWatch(ServerPlayerEntity player, DimensionalChunkPos chunkPos) {
if (isChunkManagedByVanilla(player, chunkPos)) {
return;
}
if (SGlobal.chunkTrackingGraph.isChunkDataSent(player, chunkPos)) {
return;
}
McHelper.getServer().getProfiler().push("begin_watch");
SGlobal.chunkTrackingGraph.onChunkDataSent(player, chunkPos);
IEThreadedAnvilChunkStorage ieStorage = McHelper.getIEStorage(chunkPos.dimension);
if (SGlobal.isChunkLoadingMultiThreaded) {
sendPacketMultiThreaded(player, chunkPos, ieStorage);
} else {
sendPacketNormally(player, chunkPos, ieStorage);
}
McHelper.getServer().getProfiler().pop();
}
use of com.qouteall.immersive_portals.ducks.IEThreadedAnvilChunkStorage in project ImmersivePortalsMod by qouteall.
the class ChunkDataSyncManager method onPlayerRespawn.
public void onPlayerRespawn(ServerPlayerEntity oldPlayer) {
SGlobal.chunkTrackingGraph.onPlayerRespawn(oldPlayer);
McHelper.getServer().getWorlds().forEach(world -> {
ServerChunkManager chunkManager = (ServerChunkManager) world.getChunkManager();
IEThreadedAnvilChunkStorage storage = (IEThreadedAnvilChunkStorage) chunkManager.threadedAnvilChunkStorage;
storage.onPlayerRespawn(oldPlayer);
});
}
use of com.qouteall.immersive_portals.ducks.IEThreadedAnvilChunkStorage 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 com.qouteall.immersive_portals.ducks.IEThreadedAnvilChunkStorage in project ImmersivePortalsMod by qouteall.
the class ChunkDataSyncManager method sendWatchPackets.
private void sendWatchPackets(ServerPlayerEntity player, DimensionalChunkPos chunkPos, IEThreadedAnvilChunkStorage ieStorage) {
McHelper.getServer().getProfiler().push("send_chunk_data");
Chunk chunk = McHelper.getServer().getWorld(chunkPos.dimension).getChunk(chunkPos.x, chunkPos.z);
assert chunk != null;
assert !(chunk instanceof EmptyChunk);
player.networkHandler.sendPacket(MyNetwork.createRedirectedMessage(chunkPos.dimension, new ChunkDataS2CPacket(((WorldChunk) chunk), 65535)));
player.networkHandler.sendPacket(MyNetwork.createRedirectedMessage(chunkPos.dimension, new LightUpdateS2CPacket(chunkPos.getChunkPos(), ieStorage.getLightingProvider())));
// update the entity trackers
((ThreadedAnvilChunkStorage) ieStorage).updateCameraPosition(player);
McHelper.getServer().getProfiler().pop();
}
use of com.qouteall.immersive_portals.ducks.IEThreadedAnvilChunkStorage in project ImmersivePortalsMod by qouteall.
the class MixinChunkHolder method sendPacketToPlayersWatching.
/**
* @author qouteall
*/
@Overwrite
private void sendPacketToPlayersWatching(Packet<?> packet_1, boolean boolean_1) {
DimensionType dimension = ((IEThreadedAnvilChunkStorage) playersWatchingChunkProvider).getWorld().dimension.getType();
Streams.concat(this.playersWatchingChunkProvider.getPlayersWatchingChunk(this.pos, boolean_1), SGlobal.chunkTrackingGraph.getPlayersViewingChunk(dimension, pos)).distinct().forEach(player -> player.networkHandler.sendPacket(MyNetwork.createRedirectedMessage(dimension, packet_1)));
}
Aggregations