Search in sources :

Example 1 with MyClientChunkManager

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;
        }
    });
}
Also used : IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) IEClientPlayNetworkHandler(com.qouteall.immersive_portals.ducks.IEClientPlayNetworkHandler) MinecraftClient(net.minecraft.client.MinecraftClient) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) ClientWorld(net.minecraft.client.world.ClientWorld) MyClientChunkManager(com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler) IEClientPlayNetworkHandler(com.qouteall.immersive_portals.ducks.IEClientPlayNetworkHandler)

Example 2 with MyClientChunkManager

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;
}
Also used : MyClientChunkManager(com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager) LiteralText(net.minecraft.text.LiteralText)

Example 3 with MyClientChunkManager

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);
}
Also used : IEWorld(com.qouteall.immersive_portals.ducks.IEWorld) IEClientWorld(com.qouteall.immersive_portals.ducks.IEClientWorld) ClientWorld(net.minecraft.client.world.ClientWorld) MyClientChunkManager(com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

MyClientChunkManager (com.qouteall.immersive_portals.chunk_loading.MyClientChunkManager)3 IEClientWorld (com.qouteall.immersive_portals.ducks.IEClientWorld)2 ClientWorld (net.minecraft.client.world.ClientWorld)2 IEClientPlayNetworkHandler (com.qouteall.immersive_portals.ducks.IEClientPlayNetworkHandler)1 IEWorld (com.qouteall.immersive_portals.ducks.IEWorld)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)1 LiteralText (net.minecraft.text.LiteralText)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1