package com.five35.minecraft.deathbox.client;

import com.five35.minecraft.deathbox.DeathBox;
import com.five35.minecraft.deathbox.DeathBoxTileEntity;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
import java.util.Map;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

public class DeathBoxRenderer extends TileEntitySpecialRenderer {
	private final DeathBoxModel model = new DeathBoxModel();
	private final SkinManager skinManager;

	public DeathBoxRenderer(final SkinManager skinManager) {
		this.skinManager = skinManager;
	}

	@Override
	public void renderTileEntityAt(final TileEntity tileEntity, final double x, final double y, final double z, final float partialTicks) {
		ResourceLocation texture = AbstractClientPlayer.locationStevePng;

		final DeathBoxTileEntity deathBox = (DeathBoxTileEntity) tileEntity;
		final GameProfile owner = deathBox.getOwner();

		if (owner == null) {
			DeathBox.getProxy().getLogger().warn("Rendering death box with no owner at %d,%d,%d!", x, y, z);
		} else {
			final Map<Type, MinecraftProfileTexture> profileTextures = this.skinManager.func_152788_a(owner);

			if (profileTextures.containsKey(Type.SKIN)) {
				texture = this.skinManager.func_152792_a(profileTextures.get(Type.SKIN), Type.SKIN);
			}
		}

		this.bindTexture(texture);

		GL11.glPushMatrix();

		final float age = deathBox.getAge() + partialTicks;
		final double bobHeight = 0.5 + Math.sin(age * Math.PI / 50) / 4;

		GL11.glDisable(GL11.GL_CULL_FACE);
		GL11.glTranslated(x + 0.5, y + bobHeight, z + 0.5);
		GL11.glEnable(GL12.GL_RESCALE_NORMAL);
		GL11.glScaled(-1, -1, 1);
		GL11.glEnable(GL11.GL_ALPHA_TEST);
		this.model.render(null, 0, 0, 0, 3 * age, 0, 0.0625f);

		GL11.glPopMatrix();
	}
}

@@ -343,56 +343,22 @@
 ort 
-net.minecraft.client.entity.AbstractClientPlayer
+java.util.UUID
 ;%0Aim
@@ -426,24 +426,81 @@
 alRenderer;%0A
+import net.minecraft.client.resources.DefaultPlayerSkin;%0A
 import net.m
@@ -1092,16 +1092,40 @@
 ialTicks
+, final int destroyStage
 ) %7B%0A%09%09Re
@@ -1153,45 +1153,56 @@
 e = 
-AbstractClientPlayer.locationStevePng
+DefaultPlayerSkin.getDefaultSkin(new UUID(0, 0))
 ;%0A%0A%09
@@ -1538,21 +1538,25 @@
 ger.
-func_152788_a
+loadSkinFromCache
 (own
@@ -1645,21 +1645,16 @@
 ger.
-func_152792_a
+loadSkin
 (pro
@@ -1694,16 +1694,91 @@
 .SKIN);%0A
+%09%09%09%7D else %7B%0A%09%09%09%09texture = DefaultPlayerSkin.getDefaultSkin(owner.getId());%0A
 %09%09%09%7D%0A%09%09%7D

update renderer for 1.8