Search in sources :

Example 6 with GameMode

use of net.minecraft.world.GameMode in project ImmersivePortalsMod by qouteall.

the class MyGameRenderer method renderWorld.

public void renderWorld(float partialTicks, WorldRenderer newWorldRenderer, ClientWorld newWorld, Vec3d oldCameraPos) {
    ChunkRenderDispatcher chunkRenderDispatcher = ((IEWorldRenderer) newWorldRenderer).getChunkRenderDispatcher();
    chunkRenderDispatcher.updateCameraPosition(mc.player.x, mc.player.z);
    IEGameRenderer ieGameRenderer = (IEGameRenderer) mc.gameRenderer;
    DimensionRenderHelper helper = CGlobal.clientWorldLoader.getDimensionRenderHelper(newWorld.dimension.getType());
    PlayerListEntry playerListEntry = CHelper.getClientPlayerListEntry();
    Camera newCamera = new Camera();
    // store old state
    WorldRenderer oldWorldRenderer = mc.worldRenderer;
    ClientWorld oldWorld = mc.world;
    LightmapTextureManager oldLightmap = ieGameRenderer.getLightmapTextureManager();
    BackgroundRenderer oldFogRenderer = ieGameRenderer.getBackgroundRenderer();
    GameMode oldGameMode = playerListEntry.getGameMode();
    boolean oldNoClip = mc.player.noClip;
    boolean oldDoRenderHand = ieGameRenderer.getDoRenderHand();
    List oldChunkInfos = ((IEWorldRenderer) mc.worldRenderer).getChunkInfos();
    IEChunkRenderList oldChunkRenderList = (IEChunkRenderList) ((IEWorldRenderer) oldWorldRenderer).getChunkRenderList();
    // List<ChunkRenderer> oldChunkRenderers = oldChunkRenderList.getChunkRenderers();
    OFInterface.createNewRenderInfosNormal.accept(newWorldRenderer);
    // switch
    mc.worldRenderer = newWorldRenderer;
    mc.world = newWorld;
    ieGameRenderer.setBackgroundRenderer(helper.fogRenderer);
    ieGameRenderer.setLightmapTextureManager(helper.lightmapTexture);
    helper.lightmapTexture.update(0);
    helper.lightmapTexture.enable();
    BlockEntityRenderDispatcher.INSTANCE.world = newWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(GameMode.SPECTATOR);
    mc.player.noClip = true;
    ieGameRenderer.setDoRenderHand(false);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.pushMatrix();
    CGlobal.renderInfoNumMap.put(newWorld.dimension.getType(), ((IEWorldRenderer) mc.worldRenderer).getChunkInfos().size());
    updateCullingPlane();
    // this is important
    GlStateManager.disableBlend();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GuiLighting.disable();
    ((GameRenderer) ieGameRenderer).disableLightmap();
    mc.getProfiler().push("render_portal_content");
    CGlobal.switchedFogRenderer = ieGameRenderer.getBackgroundRenderer();
    // invoke it!
    OFInterface.beforeRenderCenter.accept(partialTicks);
    ieGameRenderer.renderCenter_(partialTicks, getChunkUpdateFinishTime());
    OFInterface.afterRenderCenter.run();
    mc.getProfiler().pop();
    // recover
    mc.worldRenderer = oldWorldRenderer;
    mc.world = oldWorld;
    ieGameRenderer.setBackgroundRenderer(oldFogRenderer);
    ieGameRenderer.setLightmapTextureManager(oldLightmap);
    BlockEntityRenderDispatcher.INSTANCE.world = oldWorld;
    ((IEPlayerListEntry) playerListEntry).setGameMode(oldGameMode);
    mc.player.noClip = oldNoClip;
    ieGameRenderer.setDoRenderHand(oldDoRenderHand);
    GlStateManager.matrixMode(GL11.GL_MODELVIEW);
    GlStateManager.popMatrix();
    GlStateManager.enableBlend();
    ((IEWorldRenderer) mc.worldRenderer).setChunkInfos(oldChunkInfos);
    oldChunkRenderList.setCameraPos(oldCameraPos.x, oldCameraPos.y, oldCameraPos.z);
}
Also used : IEWorldRenderer(com.qouteall.immersive_portals.ducks.IEWorldRenderer) IEPlayerListEntry(com.qouteall.immersive_portals.ducks.IEPlayerListEntry) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) IEGameRenderer(com.qouteall.immersive_portals.ducks.IEGameRenderer) IEWorldRenderer(com.qouteall.immersive_portals.ducks.IEWorldRenderer) IEPlayerListEntry(com.qouteall.immersive_portals.ducks.IEPlayerListEntry) GameMode(net.minecraft.world.GameMode) IEChunkRenderList(com.qouteall.immersive_portals.ducks.IEChunkRenderList) IEGameRenderer(com.qouteall.immersive_portals.ducks.IEGameRenderer) List(java.util.List) IEChunkRenderList(com.qouteall.immersive_portals.ducks.IEChunkRenderList) ClientWorld(net.minecraft.client.world.ClientWorld)

Aggregations

GameMode (net.minecraft.world.GameMode)6 ServerWorld (net.minecraft.server.world.ServerWorld)3 IEPlayerListEntry (com.qouteall.immersive_portals.ducks.IEPlayerListEntry)2 IEWorldRenderer (com.qouteall.immersive_portals.ducks.IEWorldRenderer)2 PlayerListEntry (net.minecraft.client.network.PlayerListEntry)2 IEChunkRenderList (com.qouteall.immersive_portals.ducks.IEChunkRenderList)1 IEGameRenderer (com.qouteall.immersive_portals.ducks.IEGameRenderer)1 List (java.util.List)1 ImmutableContextSet (net.luckperms.api.context.ImmutableContextSet)1 Block (net.minecraft.block.Block)1 BlockState (net.minecraft.block.BlockState)1 CommandBlock (net.minecraft.block.CommandBlock)1 JigsawBlock (net.minecraft.block.JigsawBlock)1 StructureBlock (net.minecraft.block.StructureBlock)1 BlockEntity (net.minecraft.block.entity.BlockEntity)1 BlockEntityRenderDispatcher (net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher)1 EntityRenderDispatcher (net.minecraft.client.render.entity.EntityRenderDispatcher)1 ClientWorld (net.minecraft.client.world.ClientWorld)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1