Search in sources :

Example 1 with IEWorldRenderer

use of com.qouteall.immersive_portals.ducks.IEWorldRenderer in project ImmersivePortalsMod by qouteall.

the class MyGameRenderer method renderPlayerItself.

private void renderPlayerItself(Vec3d playerPos, Vec3d playerLastTickPos, float patialTicks) {
    EntityRenderDispatcher entityRenderDispatcher = ((IEWorldRenderer) mc.worldRenderer).getEntityRenderDispatcher();
    PlayerListEntry playerListEntry = CHelper.getClientPlayerListEntry();
    GameMode originalGameMode = MyRenderHelper.originalGameMode;
    Entity player = mc.cameraEntity;
    assert player != null;
    Vec3d oldPos = player.getPos();
    Vec3d oldLastTickPos = McHelper.lastTickPosOf(player);
    GameMode oldGameMode = playerListEntry.getGameMode();
    Helper.setPosAndLastTickPos(player, playerPos, playerLastTickPos);
    ((IEPlayerListEntry) playerListEntry).setGameMode(originalGameMode);
    entityRenderDispatcher.render(player, patialTicks, false);
    Helper.setPosAndLastTickPos(player, oldPos, oldLastTickPos);
    ((IEPlayerListEntry) playerListEntry).setGameMode(oldGameMode);
}
Also used : GameMode(net.minecraft.world.GameMode) Entity(net.minecraft.entity.Entity) IEWorldRenderer(com.qouteall.immersive_portals.ducks.IEWorldRenderer) IEPlayerListEntry(com.qouteall.immersive_portals.ducks.IEPlayerListEntry) PlayerListEntry(net.minecraft.client.network.PlayerListEntry) IEPlayerListEntry(com.qouteall.immersive_portals.ducks.IEPlayerListEntry) Vec3d(net.minecraft.util.math.Vec3d) EntityRenderDispatcher(net.minecraft.client.render.entity.EntityRenderDispatcher) BlockEntityRenderDispatcher(net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher)

Example 2 with IEWorldRenderer

use of com.qouteall.immersive_portals.ducks.IEWorldRenderer 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

IEPlayerListEntry (com.qouteall.immersive_portals.ducks.IEPlayerListEntry)2 IEWorldRenderer (com.qouteall.immersive_portals.ducks.IEWorldRenderer)2 PlayerListEntry (net.minecraft.client.network.PlayerListEntry)2 GameMode (net.minecraft.world.GameMode)2 IEChunkRenderList (com.qouteall.immersive_portals.ducks.IEChunkRenderList)1 IEGameRenderer (com.qouteall.immersive_portals.ducks.IEGameRenderer)1 List (java.util.List)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 Vec3d (net.minecraft.util.math.Vec3d)1