Search in sources :

Example 1 with ObjectList

use of it.unimi.dsi.fastutil.objects.ObjectList in project Create_Aeronautics by Eriksonnaren.

the class AirshipContraptionRenderer method switchAndRenderTheWorld.

// code from immersive portals, test may not have been successful, code may be removed in future
private static void switchAndRenderTheWorld(ClientWorld newWorld, Vector3d thisTickCameraPos, Vector3d lastTickCameraPos, Consumer<Runnable> invokeWrapper, int renderDistance) {
    resetGlStates();
    Entity cameraEntity = client.cameraEntity;
    Vector3d oldEyePos = McHelper.getEyePos(cameraEntity);
    Vector3d oldLastTickEyePos = McHelper.getLastTickEyePos(cameraEntity);
    RegistryKey<World> oldEntityDimension = cameraEntity.level.dimension();
    ClientWorld oldEntityWorld = (ClientWorld) cameraEntity.level;
    RegistryKey<World> newDimension = newWorld.dimension();
    McHelper.setEyePos(cameraEntity, thisTickCameraPos, lastTickCameraPos);
    cameraEntity.level = newWorld;
    WorldRenderer worldRenderer = ClientWorldLoader.getWorldRenderer(newDimension);
    // CHelper.checkGlError();
    float tickDelta = RenderStates.tickDelta;
    if (com.qouteall.immersive_portals.CGlobal.useHackedChunkRenderDispatcher) {
        ((IEWorldRenderer) worldRenderer).getBuiltChunkStorage().repositionCamera(cameraEntity.getX(), cameraEntity.getZ());
    }
    IEGameRenderer ieGameRenderer = (IEGameRenderer) client.gameRenderer;
    DimensionRenderHelper helper = ClientWorldLoader.getDimensionRenderHelper(RenderDimensionRedirect.getRedirectedDimension(newDimension));
    NetworkPlayerInfo playerListEntry = Minecraft.getInstance().getConnection().getPlayerInfo(Minecraft.getInstance().player.getGameProfile().getId());
    ActiveRenderInfo newCamera = new ActiveRenderInfo();
    WorldRenderer oldWorldRenderer = client.levelRenderer;
    LightTexture oldLightmap = client.gameRenderer.lightTexture();
    GameType oldGameMode = playerListEntry.getGameMode();
    boolean oldNoClip = client.player.noPhysics;
    boolean oldDoRenderHand = ieGameRenderer.getDoRenderHand();
    OFInterface.createNewRenderInfosNormal.accept(worldRenderer);
    ObjectList oldVisibleChunks = ((IEWorldRenderer) oldWorldRenderer).getVisibleChunks();
    RayTraceResult oldCrosshairTarget = client.hitResult;
    ActiveRenderInfo oldCamera = client.gameRenderer.getMainCamera();
    ShaderGroup oldTransparencyShader = ((IEWorldRenderer) oldWorldRenderer).portal_getTransparencyShader();
    ShaderGroup newTransparencyShader = ((IEWorldRenderer) worldRenderer).portal_getTransparencyShader();
    RenderTypeBuffers oldBufferBuilder = ((IEWorldRenderer) worldRenderer).getBufferBuilderStorage();
    RenderTypeBuffers oldClientBufferBuilder = client.renderBuffers();
    boolean oldChunkCullingEnabled = client.smartCull;
    ((IEWorldRenderer) oldWorldRenderer).setVisibleChunks(new ObjectArrayList());
    int oldRenderDistance = ((IEWorldRenderer) worldRenderer).portal_getRenderDistance();
    ((IEMinecraftClient) client).setWorldRenderer(worldRenderer);
    client.level = newWorld;
    ieGameRenderer.setLightmapTextureManager(helper.lightmapTexture);
    TileEntityRendererDispatcher.instance.level = newWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(GameType.SPECTATOR);
    client.player.noPhysics = true;
    ieGameRenderer.setDoRenderHand(false);
    GlStateManager._matrixMode(5888);
    GlStateManager._pushMatrix();
    // FogRendererContext.swappingManager.pushSwapping(RenderDimensionRedirect.getRedirectedDimension(newDimension));
    ((IEParticleManager) client.particleEngine).mySetWorld(newWorld);
    if (BlockManipulationClient.remotePointedDim == newDimension) {
        client.hitResult = BlockManipulationClient.remoteHitResult;
    }
    ieGameRenderer.setCamera(newCamera);
    if (Global.useSecondaryEntityVertexConsumer) {
    // ((IEWorldRenderer)worldRenderer).setBufferBuilderStorage(secondaryBufferBuilderStorage);
    // ((IEMinecraftClient)client).setBufferBuilderStorage(secondaryBufferBuilderStorage);
    }
    // ((IEWorldRenderer)worldRenderer).portal_setRenderDistance(renderDistance);
    if (Global.looseVisibleChunkIteration) {
        client.smartCull = false;
    }
    if (!RenderStates.isDimensionRendered(newDimension)) {
        helper.lightmapTexture.updateLightTexture(0.0F);
    }
    try {
        invokeWrapper.accept(() -> {
            // /client.getProfiler().push("render_portal_content");
            client.gameRenderer.renderLevel(tickDelta, Util.getNanos(), new MatrixStack());
        // client.getProfiler().pop();
        });
    } catch (Throwable var34) {
    // limitedLogger.invoke(var34::printStackTrace);
    }
    // SodiumInterface.switchRenderingContext.apply(worldRenderer, oldSodiumContext);
    ((IEMinecraftClient) client).setWorldRenderer(oldWorldRenderer);
    client.level = oldEntityWorld;
    ieGameRenderer.setLightmapTextureManager(oldLightmap);
    TileEntityRendererDispatcher.instance.level = oldEntityWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(oldGameMode);
    client.player.noPhysics = oldNoClip;
    ieGameRenderer.setDoRenderHand(oldDoRenderHand);
    GlStateManager._matrixMode(5888);
    GlStateManager._popMatrix();
    ((IEParticleManager) client.particleEngine).mySetWorld(oldEntityWorld);
    client.hitResult = oldCrosshairTarget;
    ieGameRenderer.setCamera(oldCamera);
    // ((IEWorldRenderer)oldWorldRenderer).portal_setTransparencyShader(oldTransparencyShader);
    // ((IEWorldRenderer)worldRenderer).portal_setTransparencyShader(newTransparencyShader);
    // FogRendererContext.swappingManager.popSwapping();
    ((IEWorldRenderer) oldWorldRenderer).setVisibleChunks(oldVisibleChunks);
    ((IEWorldRenderer) worldRenderer).setBufferBuilderStorage(oldBufferBuilder);
    ((IEMinecraftClient) client).setBufferBuilderStorage(oldClientBufferBuilder);
    ((IEWorldRenderer) worldRenderer).portal_setRenderDistance(oldRenderDistance);
    if (Global.looseVisibleChunkIteration) {
        client.smartCull = oldChunkCullingEnabled;
    }
    client.getEntityRenderDispatcher().prepare(client.level, oldCamera, client.crosshairPickEntity);
    // CHelper.checkGlError();
    cameraEntity.level = oldEntityWorld;
    McHelper.setEyePos(cameraEntity, oldEyePos, oldLastTickEyePos);
    resetGlStates();
}
Also used : Entity(net.minecraft.entity.Entity) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) GameType(net.minecraft.world.GameType) AirshipWorld(com.eriksonn.createaeronautics.dimension.AirshipWorld) World(net.minecraft.world.World) ClientWorld(net.minecraft.client.world.ClientWorld) NetworkPlayerInfo(net.minecraft.client.network.play.NetworkPlayerInfo) ObjectArrayList(it.unimi.dsi.fastutil.objects.ObjectArrayList) ShaderGroup(net.minecraft.client.shader.ShaderGroup) RayTraceResult(net.minecraft.util.math.RayTraceResult) Vector3d(net.minecraft.util.math.vector.Vector3d) ObjectList(it.unimi.dsi.fastutil.objects.ObjectList) ClientWorld(net.minecraft.client.world.ClientWorld)

Example 2 with ObjectList

use of it.unimi.dsi.fastutil.objects.ObjectList in project Iris by IrisShaders.

the class MixinLevelRenderer method swap.

@Unique
private void swap() {
    ObjectList tmpList = renderChunks;
    renderChunks = savedRenderChunks;
    savedRenderChunks = tmpList;
    // TODO: If the normal chunks need a terrain update, these chunks probably do too...
    // We probably should copy it over
    boolean tmpBool = needsUpdate;
    needsUpdate = savedNeedsTerrainUpdate;
    savedNeedsTerrainUpdate = tmpBool;
    double tmp;
    tmp = lastCameraX;
    lastCameraX = savedLastCameraX;
    savedLastCameraX = tmp;
    tmp = lastCameraY;
    lastCameraY = savedLastCameraY;
    savedLastCameraY = tmp;
    tmp = lastCameraZ;
    lastCameraZ = savedLastCameraZ;
    savedLastCameraZ = tmp;
    tmp = prevCamRotX;
    prevCamRotX = savedLastCameraPitch;
    savedLastCameraPitch = tmp;
    tmp = prevCamRotY;
    prevCamRotY = savedLastCameraYaw;
    savedLastCameraYaw = tmp;
}
Also used : ObjectList(it.unimi.dsi.fastutil.objects.ObjectList) Unique(org.spongepowered.asm.mixin.Unique)

Aggregations

ObjectList (it.unimi.dsi.fastutil.objects.ObjectList)2 AirshipWorld (com.eriksonn.createaeronautics.dimension.AirshipWorld)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 ObjectArrayList (it.unimi.dsi.fastutil.objects.ObjectArrayList)1 NetworkPlayerInfo (net.minecraft.client.network.play.NetworkPlayerInfo)1 ShaderGroup (net.minecraft.client.shader.ShaderGroup)1 ClientWorld (net.minecraft.client.world.ClientWorld)1 Entity (net.minecraft.entity.Entity)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Vector3d (net.minecraft.util.math.vector.Vector3d)1 GameType (net.minecraft.world.GameType)1 World (net.minecraft.world.World)1 Unique (org.spongepowered.asm.mixin.Unique)1