Replace CustomEntityHandler with mixin magic
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package eu.crushedpixel.replaymod.video;
|
||||
|
||||
import eu.crushedpixel.replaymod.coremod.asm_Hooks;
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.video.capturer.CaptureData;
|
||||
import eu.crushedpixel.replaymod.video.capturer.WorldRenderer;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelper;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
|
||||
public class EntityRendererHandler implements WorldRenderer {
|
||||
public final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Getter
|
||||
protected final RenderOptions options;
|
||||
|
||||
public CaptureData data;
|
||||
|
||||
public EntityRendererHandler(RenderOptions options) {
|
||||
this.options = options;
|
||||
|
||||
if (options.isHideNameTags()) {
|
||||
asm_Hooks.DO_NOT_RENDER_NAME_TAGS = true;
|
||||
}
|
||||
|
||||
((IEntityRenderer) mc.entityRenderer).setHandler(this);
|
||||
}
|
||||
|
||||
public void withDisplaySize(int displayWidth, int displayHeight, Runnable runnable) {
|
||||
final int prevWidth = mc.displayWidth;
|
||||
final int prevHeight = mc.displayHeight;
|
||||
mc.displayWidth = displayWidth;
|
||||
mc.displayHeight = displayHeight;
|
||||
|
||||
runnable.run();
|
||||
|
||||
mc.displayWidth = prevWidth;
|
||||
mc.displayHeight = prevHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWorld(ReadableDimension displaySize, final float partialTicks, CaptureData data) {
|
||||
this.data = data;
|
||||
withDisplaySize(displaySize.getWidth(), displaySize.getHeight(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
renderWorld(partialTicks, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void renderWorld(float partialTicks, long finishTimeNano) {
|
||||
mc.entityRenderer.updateLightmap(partialTicks);
|
||||
|
||||
enableDepth();
|
||||
enableAlpha();
|
||||
alphaFunc(516, 0.5F);
|
||||
|
||||
mc.entityRenderer.renderWorldPass(2, partialTicks, finishTimeNano);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
((IEntityRenderer) mc.entityRenderer).setHandler(null);
|
||||
|
||||
asm_Hooks.DO_NOT_RENDER_NAME_TAGS = false;
|
||||
}
|
||||
|
||||
public static final class NoCullingClippingHelper extends ClippingHelper {
|
||||
@Override
|
||||
public boolean isBoxInFrustum(double p_78553_1_, double p_78553_3_, double p_78553_5_, double p_78553_7_, double p_78553_9_, double p_78553_11_) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public interface GluPerspective {
|
||||
void gluPerspective(float fovY, float aspect, float zNear, float zFar);
|
||||
}
|
||||
|
||||
public interface IEntityRenderer {
|
||||
void setHandler(EntityRendererHandler handler);
|
||||
EntityRendererHandler getHandler();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class CubicOpenGlFrameCapturer extends OpenGlFrameCapturer<CubicOpenGlFra
|
||||
}
|
||||
|
||||
private final int frameSize;
|
||||
public CubicOpenGlFrameCapturer(WorldRenderer<Data> worldRenderer, RenderInfo renderInfo, int frameSize) {
|
||||
public CubicOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo, int frameSize) {
|
||||
super(worldRenderer, renderInfo);
|
||||
this.frameSize = frameSize;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ public class CubicPboOpenGlFrameCapturer extends
|
||||
MultiFramePboOpenGlFrameCapturer<CubicOpenGlFrame, CubicOpenGlFrameCapturer.Data> {
|
||||
|
||||
private final int frameSize;
|
||||
public CubicPboOpenGlFrameCapturer(WorldRenderer<CubicOpenGlFrameCapturer.Data> worldRenderer,
|
||||
RenderInfo renderInfo, int frameSize) {
|
||||
public CubicPboOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo, int frameSize) {
|
||||
super(worldRenderer, renderInfo, CubicOpenGlFrameCapturer.Data.class, frameSize * frameSize);
|
||||
this.frameSize = frameSize;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public abstract class MultiFramePboOpenGlFrameCapturer<F extends Frame, D extend
|
||||
private final D[] data;
|
||||
private PixelBufferObject pbo, otherPBO;
|
||||
|
||||
public MultiFramePboOpenGlFrameCapturer(WorldRenderer<D> worldRenderer, RenderInfo renderInfo, Class<D> type, int framePixels) {
|
||||
public MultiFramePboOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo, Class<D> type, int framePixels) {
|
||||
super(worldRenderer, renderInfo);
|
||||
|
||||
data = type.getEnumConstants();
|
||||
@@ -97,6 +97,7 @@ public abstract class MultiFramePboOpenGlFrameCapturer<F extends Frame, D extend
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
pbo.delete();
|
||||
otherPBO.delete();
|
||||
}
|
||||
|
||||
@@ -19,12 +19,12 @@ import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
|
||||
public abstract class OpenGlFrameCapturer<F extends Frame, D extends CaptureData> implements FrameCapturer<F> {
|
||||
protected final WorldRenderer<D> worldRenderer;
|
||||
protected final WorldRenderer worldRenderer;
|
||||
protected final RenderInfo renderInfo;
|
||||
protected int framesDone;
|
||||
private Framebuffer frameBuffer;
|
||||
|
||||
public OpenGlFrameCapturer(WorldRenderer<D> worldRenderer, RenderInfo renderInfo) {
|
||||
public OpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo) {
|
||||
this.worldRenderer = worldRenderer;
|
||||
this.renderInfo = renderInfo;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import eu.crushedpixel.replaymod.video.frame.OpenGlFrame;
|
||||
|
||||
public class SimpleOpenGlFrameCapturer extends OpenGlFrameCapturer<OpenGlFrame, CaptureData> {
|
||||
|
||||
public SimpleOpenGlFrameCapturer(WorldRenderer<CaptureData> worldRenderer, RenderInfo renderInfo) {
|
||||
public SimpleOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo) {
|
||||
super(worldRenderer, renderInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public class SimplePboOpenGlFrameCapturer extends OpenGlFrameCapturer<OpenGlFram
|
||||
private final int bufferSize;
|
||||
private PixelBufferObject pbo, otherPBO;
|
||||
|
||||
public SimplePboOpenGlFrameCapturer(WorldRenderer<CaptureData> worldRenderer, RenderInfo renderInfo) {
|
||||
public SimplePboOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo) {
|
||||
super(worldRenderer, renderInfo);
|
||||
|
||||
ReadableDimension size = renderInfo.getFrameSize();
|
||||
@@ -81,6 +81,7 @@ public class SimplePboOpenGlFrameCapturer extends OpenGlFrameCapturer<OpenGlFram
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
pbo.delete();
|
||||
otherPBO.delete();
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class StereoscopicOpenGlFrameCapturer
|
||||
LEFT_EYE, RIGHT_EYE
|
||||
}
|
||||
|
||||
public StereoscopicOpenGlFrameCapturer(WorldRenderer<Data> worldRenderer, RenderInfo renderInfo) {
|
||||
public StereoscopicOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo) {
|
||||
super(worldRenderer, renderInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@ import eu.crushedpixel.replaymod.video.frame.StereoscopicOpenGlFrame;
|
||||
public class StereoscopicPboOpenGlFrameCapturer
|
||||
extends MultiFramePboOpenGlFrameCapturer<StereoscopicOpenGlFrame, StereoscopicOpenGlFrameCapturer.Data> {
|
||||
|
||||
public StereoscopicPboOpenGlFrameCapturer(WorldRenderer<StereoscopicOpenGlFrameCapturer.Data> worldRenderer,
|
||||
RenderInfo renderInfo) {
|
||||
public StereoscopicPboOpenGlFrameCapturer(WorldRenderer worldRenderer, RenderInfo renderInfo) {
|
||||
super(worldRenderer, renderInfo, StereoscopicOpenGlFrameCapturer.Data.class,
|
||||
renderInfo.getFrameSize().getWidth() / 2 * renderInfo.getFrameSize().getHeight());
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
public interface WorldRenderer<D extends CaptureData> extends Closeable {
|
||||
void renderWorld(ReadableDimension displaySize, float partialTicks, D data);
|
||||
public interface WorldRenderer extends Closeable {
|
||||
void renderWorld(ReadableDimension displaySize, float partialTicks, CaptureData data);
|
||||
}
|
||||
|
||||
@@ -1,117 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.video.entity;
|
||||
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.video.capturer.CubicOpenGlFrameCapturer;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class CubicEntityRenderer extends CustomEntityRenderer<CubicOpenGlFrameCapturer.Data> {
|
||||
|
||||
public CubicEntityRenderer(RenderOptions options) {
|
||||
super(options);
|
||||
|
||||
try {
|
||||
Field hookField = RenderManager.class.getField("hook");
|
||||
hookField.set(mc.getRenderManager(), this);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new Error(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException{
|
||||
super.close();
|
||||
try {
|
||||
Field hookField = RenderManager.class.getField("hook");
|
||||
hookField.set(mc.getRenderManager(), null);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new Error(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void gluPerspective(float fovY, float aspect, float zNear, float zFar) {
|
||||
super.gluPerspective(90, 1, zNear, zFar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadShader(ResourceLocation resourceLocation) {
|
||||
if (proxied.theShaderGroup != null) {
|
||||
proxied.theShaderGroup.deleteShaderGroup();
|
||||
proxied.theShaderGroup = null;
|
||||
}
|
||||
proxied.useShader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void orientCamera(float partialTicks) {
|
||||
// Rotate
|
||||
switch (data) {
|
||||
case FRONT:
|
||||
GlStateManager.rotate(0, 0.0F, 1.0F, 0.0F);
|
||||
break;
|
||||
case RIGHT:
|
||||
GlStateManager.rotate(90, 0.0F, 1.0F, 0.0F);
|
||||
break;
|
||||
case BACK:
|
||||
GlStateManager.rotate(180, 0.0F, 1.0F, 0.0F);
|
||||
break;
|
||||
case LEFT:
|
||||
GlStateManager.rotate(-90, 0.0F, 1.0F, 0.0F);
|
||||
break;
|
||||
case BOTTOM:
|
||||
GlStateManager.rotate(90, 1.0F, 0.0F, 0.0F);
|
||||
break;
|
||||
case TOP:
|
||||
GlStateManager.rotate(-90, 1.0F, 0.0F, 0.0F);
|
||||
break;
|
||||
}
|
||||
|
||||
// Minecraft goes back a little so we have to invert that
|
||||
GlStateManager.translate(0.0F, 0.0F, 0.1F);
|
||||
super.orientCamera(partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSpectatorHand(float partialTicks, int renderPass) {
|
||||
// No spectator hands during 360° view
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
// Align all particles towards the camera
|
||||
double dx = fx.prevPosX + (fx.posX - fx.prevPosX) * partialTicks - view.posX;
|
||||
double dy = fx.prevPosY + (fx.posY - fx.prevPosY) * partialTicks - view.posY;
|
||||
double dz = fx.prevPosZ + (fx.posZ - fx.prevPosZ) * partialTicks - view.posZ;
|
||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||
double yaw = -Math.atan2(dx, dz);
|
||||
|
||||
rotX = (float) Math.cos(yaw);
|
||||
rotZ = (float) Math.sin(yaw);
|
||||
rotXZ = (float) Math.cos(pitch);
|
||||
|
||||
rotYZ = (float) (-rotZ * Math.sin(pitch));
|
||||
rotXY = (float) (rotX * Math.sin(pitch));
|
||||
|
||||
super.renderParticle(fx, worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // Called by ASM
|
||||
public void beforeEntityRender(double dx, double dy, double dz) {
|
||||
double pitch = -Math.atan2(dy, Math.sqrt(dx * dx + dz * dz));
|
||||
double yaw = -Math.atan2(dx, dz);
|
||||
mc.getRenderManager().playerViewX = (float) Math.toDegrees(pitch);
|
||||
mc.getRenderManager().playerViewY = (float) Math.toDegrees(yaw);
|
||||
}
|
||||
}
|
||||
@@ -1,465 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.video.entity;
|
||||
|
||||
import eu.crushedpixel.replaymod.coremod.asm_Hooks;
|
||||
import eu.crushedpixel.replaymod.renderer.SpectatorRenderer;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.video.capturer.CaptureData;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EffectRenderer;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
import org.lwjgl.util.glu.Project;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class CustomEntityRenderer<D extends CaptureData> implements eu.crushedpixel.replaymod.video.capturer.WorldRenderer<D> {
|
||||
public final Minecraft mc = Minecraft.getMinecraft();
|
||||
public final EntityRenderer proxied = mc.entityRenderer;
|
||||
protected final SpectatorRenderer spectatorRenderer = new SpectatorRenderer(){
|
||||
@Override
|
||||
protected void gluPerspective(float fovY, float aspect, float zNear, float zFar) {
|
||||
CustomEntityRenderer.this.gluPerspective(fovY, aspect, zNear, zFar);
|
||||
}
|
||||
};
|
||||
|
||||
public GluPerspectiveHook gluPerspectiveHook;
|
||||
public LoadShaderHook loadShaderHook;
|
||||
protected int frameCount;
|
||||
|
||||
protected D data;
|
||||
|
||||
protected final RenderOptions options;
|
||||
|
||||
|
||||
public CustomEntityRenderer(RenderOptions options) {
|
||||
this.options = options;
|
||||
|
||||
// Install entity renderer hooks
|
||||
try {
|
||||
Field hookField = EntityRenderer.class.getField("hook");
|
||||
hookField.set(proxied, this);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new Error(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
|
||||
if (options.isHideNameTags()) {
|
||||
asm_Hooks.DO_NOT_RENDER_NAME_TAGS = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // Method called by ASM hook
|
||||
public void loadShader(ResourceLocation resourceLocation) {
|
||||
if (loadShaderHook != null) {
|
||||
loadShaderHook.loadShader(resourceLocation);
|
||||
} else {
|
||||
original_loadShader(resourceLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
protected final void original_loadShader(ResourceLocation resourceLocation) {
|
||||
// Method body generated by ASM
|
||||
}
|
||||
|
||||
protected void gluPerspective(float fovY, float aspect, float zNear, float zFar) {
|
||||
if (gluPerspectiveHook == null) {
|
||||
Project.gluPerspective(fovY, aspect, zNear, zFar);
|
||||
} else {
|
||||
gluPerspectiveHook.gluPerspective(fovY, aspect, zNear, zFar);
|
||||
}
|
||||
}
|
||||
|
||||
public void withDisplaySize(int displayWidth, int displayHeight, Runnable runnable) {
|
||||
final int prevWidth = mc.displayWidth;
|
||||
final int prevHeight = mc.displayHeight;
|
||||
mc.displayWidth = displayWidth;
|
||||
mc.displayHeight = displayHeight;
|
||||
|
||||
runnable.run();
|
||||
|
||||
mc.displayWidth = prevWidth;
|
||||
mc.displayHeight = prevHeight;
|
||||
}
|
||||
|
||||
public void renderWorld(float partialTicks, long finishTimeNano) {
|
||||
proxied.updateLightmap(partialTicks);
|
||||
|
||||
enableDepth();
|
||||
enableAlpha();
|
||||
alphaFunc(516, 0.5F);
|
||||
|
||||
renderWorldPass(partialTicks, finishTimeNano, 2);
|
||||
}
|
||||
|
||||
protected void renderWorldPass(float partialTicks, long finishTimeNano, int renderPass) {
|
||||
RenderGlobal renderglobal = mc.renderGlobal;
|
||||
Entity entity = mc.getRenderViewEntity();
|
||||
enableCull();
|
||||
viewport(0, 0, mc.displayWidth, mc.displayHeight);
|
||||
proxied.updateFogColor(partialTicks);
|
||||
clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
setupCameraTransform(partialTicks);
|
||||
ActiveRenderInfo.updateRenderInfo(mc.thePlayer, mc.gameSettings.thirdPersonView == 2);
|
||||
ClippingHelperImpl.getInstance();
|
||||
ICamera camera = new NoCullingCamera();
|
||||
|
||||
if (this.mc.gameSettings.renderDistanceChunks >= 4 || !options.isDefaultSky() ) {
|
||||
setupFog(-1, partialTicks);
|
||||
matrixMode(GL_PROJECTION);
|
||||
loadIdentity();
|
||||
gluPerspective(proxied.getFOVModifier(partialTicks, true), (float) mc.displayWidth / mc.displayHeight, 0.05F, proxied.farPlaneDistance * 2.0F);
|
||||
matrixMode(GL_MODELVIEW);
|
||||
if (options.isDefaultSky()) {
|
||||
renderglobal.renderSky(partialTicks, renderPass);
|
||||
} else {
|
||||
int c = options.getSkyColor();
|
||||
clearColor((c >> 16 & 0xff) / (float) 0xff, (c >> 8 & 0xff) / (float) 0xff, (c & 0xff) / (float) 0xff, 1);
|
||||
clear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
matrixMode(GL_PROJECTION);
|
||||
loadIdentity();
|
||||
gluPerspective(proxied.getFOVModifier(partialTicks, true), (float) mc.displayWidth / mc.displayHeight, 0.05F, proxied.farPlaneDistance * MathHelper.SQRT_2);
|
||||
matrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
setupFog(0, partialTicks);
|
||||
shadeModel(GL_SMOOTH);
|
||||
|
||||
if (entity.posY + entity.getEyeHeight() < 128) {
|
||||
renderCloudsCheck(renderglobal, partialTicks, renderPass);
|
||||
}
|
||||
|
||||
setupFog(0, partialTicks);
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
renderglobal.setupTerrain(entity, partialTicks, camera, frameCount++, mc.thePlayer.isSpectator());
|
||||
|
||||
renderglobal.updateChunks(finishTimeNano);
|
||||
|
||||
matrixMode(GL_MODELVIEW);
|
||||
pushMatrix();
|
||||
disableAlpha();
|
||||
renderglobal.renderBlockLayer(EnumWorldBlockLayer.SOLID, partialTicks, renderPass, entity);
|
||||
enableAlpha();
|
||||
renderglobal.renderBlockLayer(EnumWorldBlockLayer.CUTOUT_MIPPED, partialTicks, renderPass, entity);
|
||||
mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false);
|
||||
renderglobal.renderBlockLayer(EnumWorldBlockLayer.CUTOUT, partialTicks, renderPass, entity);
|
||||
mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
|
||||
shadeModel(GL_FLAT);
|
||||
alphaFunc(516, 0.1F);
|
||||
|
||||
matrixMode(GL_MODELVIEW);
|
||||
popMatrix();
|
||||
pushMatrix();
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
|
||||
net.minecraftforge.client.ForgeHooksClient.setRenderPass(0);
|
||||
renderglobal.renderEntities(entity, camera, partialTicks);
|
||||
net.minecraftforge.client.ForgeHooksClient.setRenderPass(0);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
proxied.disableLightmap();
|
||||
matrixMode(GL_MODELVIEW);
|
||||
popMatrix();
|
||||
|
||||
enableBlend();
|
||||
tryBlendFuncSeparate(770, 1, 1, 0);
|
||||
renderglobal.drawBlockDamageTexture(Tessellator.getInstance(), Tessellator.getInstance().getWorldRenderer(), entity, partialTicks);
|
||||
disableBlend();
|
||||
|
||||
renderParticles(entity, partialTicks);
|
||||
|
||||
depthMask(false);
|
||||
enableCull();
|
||||
proxied.renderRainSnow(partialTicks);
|
||||
depthMask(true);
|
||||
renderglobal.renderWorldBorder(entity, partialTicks);
|
||||
disableBlend();
|
||||
enableCull();
|
||||
tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
alphaFunc(516, 0.1F);
|
||||
setupFog(0, partialTicks);
|
||||
enableBlend();
|
||||
depthMask(false);
|
||||
mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
||||
shadeModel(GL_SMOOTH);
|
||||
|
||||
if (mc.gameSettings.fancyGraphics) {
|
||||
enableBlend();
|
||||
tryBlendFuncSeparate(770, 771, 1, 0);
|
||||
renderglobal.renderBlockLayer(EnumWorldBlockLayer.TRANSLUCENT, partialTicks, renderPass, entity);
|
||||
disableBlend();
|
||||
} else {
|
||||
renderglobal.renderBlockLayer(EnumWorldBlockLayer.TRANSLUCENT, partialTicks, renderPass, entity);
|
||||
}
|
||||
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
net.minecraftforge.client.ForgeHooksClient.setRenderPass(1);
|
||||
renderglobal.renderEntities(entity, camera, partialTicks);
|
||||
net.minecraftforge.client.ForgeHooksClient.setRenderPass(-1);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
shadeModel(GL_FLAT);
|
||||
depthMask(true);
|
||||
enableCull();
|
||||
disableBlend();
|
||||
disableFog();
|
||||
|
||||
if (entity.posY + entity.getEyeHeight() >= 128) {
|
||||
renderCloudsCheck(renderglobal, partialTicks, renderPass);
|
||||
}
|
||||
|
||||
net.minecraftforge.client.ForgeHooksClient.dispatchRenderLast(renderglobal, partialTicks);
|
||||
|
||||
renderSpectatorHand(partialTicks, renderPass);
|
||||
}
|
||||
|
||||
protected void renderParticles(Entity entity, float partialTicks) {
|
||||
proxied.enableLightmap();
|
||||
renderLitParticles(entity, partialTicks);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
setupFog(0, partialTicks);
|
||||
renderNormalParticles(entity, partialTicks);
|
||||
proxied.disableLightmap();
|
||||
}
|
||||
|
||||
protected void renderLitParticles(Entity entity, float partialTicks) {
|
||||
EffectRenderer effectRenderer = mc.effectRenderer;
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||
|
||||
double yaw = Math.toRadians(entity.rotationYaw);
|
||||
double pitch = Math.toRadians(entity.rotationPitch);
|
||||
|
||||
float rotX = (float) Math.cos(yaw);
|
||||
float rotZ = (float) Math.sin(yaw);
|
||||
float rotXZ = (float) Math.cos(pitch);
|
||||
|
||||
float rotYZ = (float) (-rotZ * Math.sin(pitch));
|
||||
float rotXY = (float) (rotX * Math.sin(pitch));
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityFX> list = (List<EntityFX>) effectRenderer.fxLayers[3][i];
|
||||
for (EntityFX fx : list) {
|
||||
worldrenderer.setBrightness(fx.getBrightnessForRender(partialTicks));
|
||||
renderParticle(fx, worldrenderer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderNormalParticles(Entity entity, float partialTicks) {
|
||||
EffectRenderer effectRenderer = mc.effectRenderer;
|
||||
TextureManager textureManager = mc.getTextureManager();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
|
||||
|
||||
double yaw = Math.toRadians(entity.rotationYaw);
|
||||
double pitch = Math.toRadians(entity.rotationPitch);
|
||||
|
||||
float rotX = (float) Math.cos(yaw);
|
||||
float rotZ = (float) Math.sin(yaw);
|
||||
float rotXZ = (float) Math.cos(pitch);
|
||||
|
||||
float rotYZ = (float) (-rotZ * Math.sin(pitch));
|
||||
float rotXY = (float) (rotX * Math.sin(pitch));
|
||||
|
||||
EntityFX.interpPosX = entity.posX;
|
||||
EntityFX.interpPosY = entity.posY;
|
||||
EntityFX.interpPosZ = entity.posZ;
|
||||
|
||||
enableBlend();
|
||||
blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
alphaFunc(GL_GREATER, 0.003921569F);
|
||||
|
||||
for (int texture = 0; texture < 3; texture++) {
|
||||
for (int depthMask = 0; depthMask < 2; depthMask++) {
|
||||
if (effectRenderer.fxLayers[texture][depthMask].isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (depthMask == 0) {
|
||||
GlStateManager.depthMask(false);
|
||||
} else {
|
||||
GlStateManager.depthMask(true);
|
||||
}
|
||||
|
||||
if (texture == 1) {
|
||||
textureManager.bindTexture(TextureMap.locationBlocksTexture);
|
||||
} else {
|
||||
textureManager.bindTexture(EffectRenderer.particleTextures);
|
||||
}
|
||||
|
||||
color(1, 1, 1, 1);
|
||||
worldRenderer.startDrawingQuads();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityFX> list = (List<EntityFX>) effectRenderer.fxLayers[texture][depthMask];
|
||||
for (final EntityFX fx : list) {
|
||||
worldRenderer.setBrightness(fx.getBrightnessForRender(partialTicks));
|
||||
renderParticle(fx, worldRenderer, entity, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
depthMask(true);
|
||||
disableBlend();
|
||||
alphaFunc(516, 0.1F);
|
||||
}
|
||||
|
||||
protected void renderParticle(EntityFX fx, WorldRenderer worldRenderer, Entity view, float partialTicks,
|
||||
float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
|
||||
fx.func_180434_a(worldRenderer, view, partialTicks, rotX, rotXZ, rotZ, rotYZ, rotXY);
|
||||
}
|
||||
|
||||
protected void renderSpectatorHand(float partialTicks, int renderPass) {
|
||||
Entity currentEntity = ReplayHandler.getCurrentEntity();
|
||||
if(!ReplayHandler.isCamera() && currentEntity instanceof EntityPlayer) {
|
||||
spectatorRenderer.renderSpectatorHand((EntityPlayer) currentEntity, partialTicks, renderPass);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupCameraTransform(float partialTicks) {
|
||||
Entity entity = mc.getRenderViewEntity();
|
||||
float orgYaw = entity.rotationYaw;
|
||||
float orgPitch = entity.rotationPitch;
|
||||
float orgPrevYaw = entity.prevRotationYaw;
|
||||
float orgPrevPitch = entity.prevRotationPitch;
|
||||
float orgRoll = ReplayHandler.getCameraTilt();
|
||||
|
||||
proxied.farPlaneDistance = (float)(this.mc.gameSettings.renderDistanceChunks * 16);
|
||||
|
||||
matrixMode(GL_PROJECTION);
|
||||
loadIdentity();
|
||||
|
||||
gluPerspective(proxied.getFOVModifier(partialTicks, true), (float) this.mc.displayWidth / (float) this.mc.displayHeight, 0.05F, proxied.farPlaneDistance * MathHelper.SQRT_2);
|
||||
|
||||
matrixMode(GL_MODELVIEW);
|
||||
loadIdentity();
|
||||
|
||||
orientCamera(partialTicks);
|
||||
|
||||
entity.rotationYaw = orgYaw;
|
||||
entity.rotationPitch = orgPitch;
|
||||
entity.prevRotationYaw = orgPrevYaw;
|
||||
entity.prevRotationPitch = orgPrevPitch;
|
||||
ReplayHandler.setCameraTilt(orgRoll);
|
||||
}
|
||||
|
||||
protected void setupFog(int fogDistanceFlag, float partialTicks) {
|
||||
if (options.isDefaultSky()) {
|
||||
proxied.setupFog(fogDistanceFlag, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
protected void orientCamera(float partialTicks) {
|
||||
Entity entity = mc.getRenderViewEntity();
|
||||
if (options.getIgnoreCameraRotation()[0]) {
|
||||
entity.prevRotationYaw = entity.rotationYaw = 0;
|
||||
}
|
||||
if (options.getIgnoreCameraRotation()[1]) {
|
||||
entity.prevRotationPitch = entity.rotationPitch = 0;
|
||||
}
|
||||
if (options.getIgnoreCameraRotation()[2]) {
|
||||
ReplayHandler.setCameraTilt(0);
|
||||
}
|
||||
|
||||
proxied.orientCamera(partialTicks);
|
||||
}
|
||||
|
||||
protected void renderCloudsCheck(RenderGlobal renderglobal, float partialTicks, int renderPass) {
|
||||
if (this.mc.gameSettings.shouldRenderClouds()) {
|
||||
matrixMode(GL_PROJECTION);
|
||||
loadIdentity();
|
||||
gluPerspective(proxied.getFOVModifier(partialTicks, true), (float) this.mc.displayWidth / (float) this.mc.displayHeight, 0.05F, proxied.farPlaneDistance * 4.0F);
|
||||
matrixMode(GL_MODELVIEW);
|
||||
pushMatrix();
|
||||
setupFog(0, partialTicks);
|
||||
renderglobal.renderClouds(partialTicks, renderPass);
|
||||
disableFog();
|
||||
popMatrix();
|
||||
matrixMode(GL_PROJECTION);
|
||||
loadIdentity();
|
||||
gluPerspective(proxied.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, proxied.farPlaneDistance * MathHelper.SQRT_2);
|
||||
matrixMode(GL_MODELVIEW);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
Field hookField = EntityRenderer.class.getField("hook");
|
||||
hookField.set(proxied, null);
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new Error(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
|
||||
asm_Hooks.DO_NOT_RENDER_NAME_TAGS = false;
|
||||
|
||||
spectatorRenderer.cleanup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderWorld(ReadableDimension displaySize, final float partialTicks, D data) {
|
||||
this.data = data;
|
||||
withDisplaySize(displaySize.getWidth(), displaySize.getHeight(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
renderWorld(partialTicks, 0);
|
||||
if (OpenGlHelper.shadersSupported) {
|
||||
if (proxied.theShaderGroup != null && proxied.useShader) {
|
||||
matrixMode(GL_TEXTURE);
|
||||
|
||||
pushMatrix();
|
||||
loadIdentity();
|
||||
proxied.theShaderGroup.loadShaderGroup(partialTicks);
|
||||
popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static final class NoCullingCamera implements ICamera {
|
||||
|
||||
@Override
|
||||
public boolean isBoundingBoxInFrustum(AxisAlignedBB p_78546_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double p_78547_1_, double p_78547_3_, double p_78547_5_) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface GluPerspectiveHook {
|
||||
void gluPerspective(float fovY, float aspect, float zNear, float zFar);
|
||||
}
|
||||
|
||||
public interface LoadShaderHook {
|
||||
void loadShader(ResourceLocation resourceLocation);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package eu.crushedpixel.replaymod.video.entity;
|
||||
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.video.capturer.StereoscopicOpenGlFrameCapturer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.loadIdentity;
|
||||
import static net.minecraft.client.renderer.GlStateManager.matrixMode;
|
||||
import static org.lwjgl.opengl.GL11.GL_MODELVIEW;
|
||||
import static org.lwjgl.opengl.GL11.GL_PROJECTION;
|
||||
|
||||
public class StereoscopicEntityRenderer extends CustomEntityRenderer<StereoscopicOpenGlFrameCapturer.Data> {
|
||||
|
||||
public StereoscopicEntityRenderer(RenderOptions options) {
|
||||
super(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadShader(ResourceLocation resourceLocation) {
|
||||
if (proxied.theShaderGroup != null) {
|
||||
proxied.theShaderGroup.deleteShaderGroup();
|
||||
proxied.theShaderGroup = null;
|
||||
}
|
||||
proxied.useShader = false;
|
||||
}
|
||||
|
||||
protected void translateStereoscopic() {
|
||||
GlStateManager.translate(data == StereoscopicOpenGlFrameCapturer.Data.LEFT_EYE ? 0.07 : -0.07, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupCameraTransform(float partialTicks) {
|
||||
proxied.farPlaneDistance = (float)(this.mc.gameSettings.renderDistanceChunks * 16);
|
||||
|
||||
matrixMode(GL_PROJECTION);
|
||||
loadIdentity();
|
||||
translateStereoscopic();
|
||||
|
||||
gluPerspective(proxied.getFOVModifier(partialTicks, true), (float) this.mc.displayWidth / (float) this.mc.displayHeight, 0.05F, proxied.farPlaneDistance * MathHelper.SQRT_2);
|
||||
|
||||
matrixMode(GL_MODELVIEW);
|
||||
loadIdentity();
|
||||
translateStereoscopic();
|
||||
|
||||
orientCamera(partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderSpectatorHand(float partialTicks, int renderPass) {
|
||||
super.renderSpectatorHand(partialTicks, data == StereoscopicOpenGlFrameCapturer.Data.LEFT_EYE ? 1 : 0);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,8 @@ package eu.crushedpixel.replaymod.video.rendering;
|
||||
|
||||
import eu.crushedpixel.replaymod.opengl.PixelBufferObject;
|
||||
import eu.crushedpixel.replaymod.settings.RenderOptions;
|
||||
import eu.crushedpixel.replaymod.video.EntityRendererHandler;
|
||||
import eu.crushedpixel.replaymod.video.capturer.*;
|
||||
import eu.crushedpixel.replaymod.video.entity.CubicEntityRenderer;
|
||||
import eu.crushedpixel.replaymod.video.entity.CustomEntityRenderer;
|
||||
import eu.crushedpixel.replaymod.video.entity.StereoscopicEntityRenderer;
|
||||
import eu.crushedpixel.replaymod.video.frame.CubicOpenGlFrame;
|
||||
import eu.crushedpixel.replaymod.video.frame.OpenGlFrame;
|
||||
import eu.crushedpixel.replaymod.video.frame.RGBFrame;
|
||||
@@ -40,9 +38,9 @@ public class Pipelines {
|
||||
RenderOptions options = renderInfo.getRenderOptions();
|
||||
FrameCapturer<OpenGlFrame> capturer;
|
||||
if (PixelBufferObject.SUPPORTED) {
|
||||
capturer = new SimplePboOpenGlFrameCapturer(new CustomEntityRenderer<CaptureData>(options), renderInfo);
|
||||
capturer = new SimplePboOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo);
|
||||
} else {
|
||||
capturer = new SimpleOpenGlFrameCapturer(new CustomEntityRenderer<CaptureData>(options), renderInfo);
|
||||
capturer = new SimpleOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo);
|
||||
}
|
||||
return new Pipeline<OpenGlFrame, RGBFrame>(capturer, new OpenGlToRGBProcessor(), consumer);
|
||||
}
|
||||
@@ -51,9 +49,9 @@ public class Pipelines {
|
||||
RenderOptions options = renderInfo.getRenderOptions();
|
||||
FrameCapturer<StereoscopicOpenGlFrame> capturer;
|
||||
if (PixelBufferObject.SUPPORTED) {
|
||||
capturer = new StereoscopicPboOpenGlFrameCapturer(new StereoscopicEntityRenderer(options), renderInfo);
|
||||
capturer = new StereoscopicPboOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo);
|
||||
} else {
|
||||
capturer = new StereoscopicOpenGlFrameCapturer(new StereoscopicEntityRenderer(options), renderInfo);
|
||||
capturer = new StereoscopicOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo);
|
||||
}
|
||||
return new Pipeline<StereoscopicOpenGlFrame, RGBFrame>(capturer, new StereoscopicToRGBProcessor(), consumer);
|
||||
}
|
||||
@@ -62,9 +60,9 @@ public class Pipelines {
|
||||
RenderOptions options = renderInfo.getRenderOptions();
|
||||
FrameCapturer<CubicOpenGlFrame> capturer;
|
||||
if (PixelBufferObject.SUPPORTED) {
|
||||
capturer = new CubicPboOpenGlFrameCapturer(new CubicEntityRenderer(options), renderInfo, options.getWidth() / 4);
|
||||
capturer = new CubicPboOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo, options.getWidth() / 4);
|
||||
} else {
|
||||
capturer = new CubicOpenGlFrameCapturer(new CubicEntityRenderer(options), renderInfo, options.getWidth() / 4);
|
||||
capturer = new CubicOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo, options.getWidth() / 4);
|
||||
}
|
||||
return new Pipeline<CubicOpenGlFrame, RGBFrame>(capturer, new CubicToRGBProcessor(), consumer);
|
||||
}
|
||||
@@ -73,9 +71,9 @@ public class Pipelines {
|
||||
RenderOptions options = renderInfo.getRenderOptions();
|
||||
FrameCapturer<CubicOpenGlFrame> capturer;
|
||||
if (PixelBufferObject.SUPPORTED) {
|
||||
capturer = new CubicPboOpenGlFrameCapturer(new CubicEntityRenderer(options), renderInfo, options.getWidth() / 4);
|
||||
capturer = new CubicPboOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo, options.getWidth() / 4);
|
||||
} else {
|
||||
capturer = new CubicOpenGlFrameCapturer(new CubicEntityRenderer(options), renderInfo, options.getWidth() / 4);
|
||||
capturer = new CubicOpenGlFrameCapturer(new EntityRendererHandler(options), renderInfo, options.getWidth() / 4);
|
||||
}
|
||||
return new Pipeline<CubicOpenGlFrame, RGBFrame>(capturer, new EquirectangularToRGBProcessor(options.getWidth() / 4), consumer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user