Realign all nametags towards the camera when rendering 360° frames

This commit is contained in:
johni0702
2015-07-06 15:52:07 +02:00
parent 13534dc94e
commit a21cf64a88
3 changed files with 115 additions and 0 deletions

View File

@@ -5,9 +5,12 @@ import eu.crushedpixel.replaymod.settings.RenderOptions;
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.lang.reflect.Field;
public class CubicEntityRenderer extends CustomEntityRenderer {
public enum Direction {
@@ -39,6 +42,28 @@ public class CubicEntityRenderer extends CustomEntityRenderer {
public CubicEntityRenderer(RenderOptions options, int frameSize, boolean stable) {
super(options, frameSize, frameSize);
this.stable = stable;
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 cleanup() {
super.cleanup();
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);
}
}
public void setFrame(int id) {
@@ -144,4 +169,12 @@ public class CubicEntityRenderer extends CustomEntityRenderer {
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);
}
}