use of com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager in project ImmersivePortalsMod by qouteall.
the class MyNetworkClient method processRedirectedPacket.
private static void processRedirectedPacket(DimensionType dimension, Packet packet) {
MinecraftClient mc = MinecraftClient.getInstance();
mc.execute(() -> {
ClientWorld packetWorld = CGlobal.clientWorldLoader.getOrCreateFakedWorld(dimension);
assert packetWorld != null;
assert packetWorld.getChunkManager() instanceof MyClientChunkManager;
ClientPlayNetworkHandler netHandler = ((IEClientWorld) packetWorld).getNetHandler();
if ((netHandler).getWorld() != packetWorld) {
((IEClientPlayNetworkHandler) netHandler).setWorld(packetWorld);
Helper.err("The world field of client net handler is wrong");
}
ClientWorld originalWorld = mc.world;
// some packet handling may use mc.world so switch it
mc.world = packetWorld;
try {
packet.apply(netHandler);
} catch (Throwable e) {
throw new IllegalStateException("handling packet in " + dimension, e);
} finally {
mc.world = originalWorld;
}
});
}
use of com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager in project ImmersivePortalsMod by qouteall.
the class MyCommandClient method reportResourceConsumption.
private static int reportResourceConsumption(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
StringBuilder str = new StringBuilder();
str.append("Client Chunk:\n");
CGlobal.clientWorldLoader.clientWorldMap.values().forEach(world -> {
str.append(String.format("%s %s\n", world.dimension.getType(), ((MyClientChunkManager) world.getChunkManager()).getChunkNum()));
});
str.append("Chunk Renderers:\n");
CGlobal.clientWorldLoader.worldRendererMap.forEach((dimension, worldRenderer) -> {
str.append(String.format("%s %s\n", dimension, ((IEChunkRenderDispatcher) ((IEWorldRenderer) worldRenderer).getChunkRenderDispatcher()).getEmployedRendererNum()));
});
str.append("Server Chunks:\n");
McHelper.getServer().getWorlds().forEach(world -> {
str.append(String.format("%s %s\n", world.dimension.getType(), world.getForcedChunks().size()));
});
String result = str.toString();
Helper.log(str);
context.getSource().getPlayer().sendMessage(new LiteralText(result));
return 0;
}
use of com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager in project ImmersivePortalsMod by qouteall.
the class MixinClientWorld method onConstructed.
@Inject(method = "Lnet/minecraft/client/world/ClientWorld;<init>(Lnet/minecraft/client/network/ClientPlayNetworkHandler;Lnet/minecraft/world/level/LevelInfo;Lnet/minecraft/world/dimension/DimensionType;ILnet/minecraft/util/profiler/Profiler;Lnet/minecraft/client/render/WorldRenderer;)V", at = @At("RETURN"))
void onConstructed(ClientPlayNetworkHandler clientPlayNetworkHandler_1, LevelInfo levelInfo_1, DimensionType dimensionType_1, int int_1, Profiler profiler_1, WorldRenderer worldRenderer_1, CallbackInfo ci) {
ClientWorld clientWorld = (ClientWorld) (Object) this;
MyClientChunkManager chunkManager = new MyClientChunkManager(clientWorld, int_1);
((IEWorld) this).setChunkManager(chunkManager);
}
Aggregations