package io.github.elytra.movingworld.client.render;

import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.culling.ICamera;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import io.github.elytra.movingworld.common.chunk.mobilechunk.MobileChunkClient;
import io.github.elytra.movingworld.common.entity.EntityMovingWorld;

public class RenderMovingWorld extends Render {
    public RenderMovingWorld(RenderManager renderManager) {
        super(renderManager);
        shadowSize = 1F;
    }

    public void renderVehicle(EntityMovingWorld entity, double x, double y, double z, float yaw, float partialTicks) {
        float pitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
        yaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks;

        float rx = entity.frontDirection.getHorizontalIndex() == 1 ? -1f : entity.frontDirection.getHorizontalIndex() == 3 ? 1f : 0f;
        float rz = entity.frontDirection.getHorizontalIndex() == 0 ? 1f : entity.frontDirection.getHorizontalIndex() == 2 ? -1f : 0f;

        GlStateManager.pushMatrix();
        GlStateManager.translate((float) x, (float) y, (float) z);
        GlStateManager.rotate(yaw, 0F, 1F, 0F);
        GlStateManager.rotate(pitch, rx, 0f, rz);

        float fx = entity.getMobileChunk().getCenterX();
        float fz = entity.getMobileChunk().getCenterZ();
        GlStateManager.translate(-fx, -entity.getMobileChunk().minY(), -fz); //minY is always 0

        bindEntityTexture(entity);
        ((MobileChunkClient) entity.getMobileChunk()).getRenderer().render(partialTicks);
        GL11.glPopMatrix();
    }

    @Override
    public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) {
        renderVehicle((EntityMovingWorld) entity, x, y, z, yaw, partialTicks);
        super.doRender(entity, x, y, z, yaw, partialTicks);
    }

    @Override
    public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
        return entity.isInRangeToRender3d(camX, camY, camZ);
    }

    @Override
    protected ResourceLocation getEntityTexture(Entity entity) {
        return TextureMap.LOCATION_BLOCKS_TEXTURE;
    }
}

@@ -325,44 +325,8 @@
 ap;%0A
-import net.minecraft.entity.Entity;%0A
 impo
@@ -397,16 +397,51 @@
 .GL11;%0A%0A
+import javax.annotation.Nullable;%0A%0A
 import i
@@ -627,16 +627,35 @@
 s Render
+%3CEntityMovingWorld%3E
  %7B%0A    p
@@ -767,24 +767,186 @@
  1F;%0A    %7D%0A%0A
+    @Nullable%0A    @Override%0A    protected ResourceLocation getEntityTexture(EntityMovingWorld entity) %7B%0A        return TextureMap.LOCATION_BLOCKS_TEXTURE;%0A    %7D%0A%0A
     public v
@@ -2149,32 +2149,43 @@
  doRender(Entity
+MovingWorld
  entity, double 
@@ -2266,28 +2266,8 @@
 cle(
-(EntityMovingWorld) 
 enti
@@ -2414,24 +2414,35 @@
 ender(Entity
+MovingWorld
  entity, ICa
@@ -2514,195 +2514,18 @@
 urn 
-entity.isInRangeToRender3d(camX, camY, camZ);%0A    %7D%0A%0A    @Override%0A    protected ResourceLocation getEntityTexture(Entity entity) %7B%0A        return TextureMap.LOCATION_BLOCKS_TEXTURE
+true
 ;%0A    %7D%0A
 %7D%0A
@@ -2522,10 +2522,11 @@
 ;%0A    %7D%0A
+%0A
 %7D%0A

Use the <T> in Render<T>