Fix up Bin rendering

This commit is contained in:
aidancbrady 2016-03-05 15:18:40 -05:00
parent 866c76bafe
commit 4e41b46df7

View file

@ -1,19 +1,16 @@
package mekanism.client.render.tileentity; package mekanism.client.render.tileentity;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.tile.TileEntityBin; import mekanism.common.tile.TileEntityBin;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -25,7 +22,7 @@ import cpw.mods.fml.relauncher.SideOnly;
public class RenderBin extends TileEntitySpecialRenderer public class RenderBin extends TileEntitySpecialRenderer
{ {
private final RenderBlocks renderBlocks = new RenderBlocks(); private final RenderBlocks renderBlocks = new RenderBlocks();
private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); private final RenderItem renderItem = new RenderItem();
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick)
@ -53,8 +50,7 @@ public class RenderBin extends TileEntitySpecialRenderer
return; return;
} }
doLight(tileEntity.getWorldObj(), obj); MekanismRenderer.glowOn();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
if(itemStack != null) if(itemStack != null)
{ {
@ -82,17 +78,13 @@ public class RenderBin extends TileEntitySpecialRenderer
float scale = 0.03125F; float scale = 0.03125F;
float scaler = 0.9F; float scaler = 0.9F;
GL11.glScalef(scale*scaler, scale*scaler, 0); GL11.glScalef(scale*scaler, scale*scaler, -0.0001F);
GL11.glRotatef(180, 0, 0, 1); GL11.glRotatef(180, 0, 0, 1);
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
renderItem.renderItemAndEffectIntoGUI(func_147498_b()/*getFontRenderer()*/, renderEngine, itemStack, 0, 0); renderItem.renderItemAndEffectIntoGUI(func_147498_b()/*getFontRenderer()*/, renderEngine, itemStack, 0, 0);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
@ -100,22 +92,9 @@ public class RenderBin extends TileEntitySpecialRenderer
{ {
renderText(amount, ForgeDirection.getOrientation(tileEntity.facing), 0.02F, x, y - 0.31F, z); renderText(amount, ForgeDirection.getOrientation(tileEntity.facing), 0.02F, x, y - 0.31F, z);
} }
}
}
private void doLight(World world, Coord4D obj) MekanismRenderer.glowOff();
{
if(world.getBlock(obj.xCoord, obj.yCoord, obj.zCoord).isOpaqueCube())
{
return;
} }
int brightness = world.getLightBrightnessForSkyBlocks(obj.xCoord, obj.yCoord, obj.zCoord, 0);
int lightX = brightness % 65536;
int lightY = brightness / 65536;
float scale = 0.6F;
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightX * scale, lightY * scale);
} }
@SuppressWarnings("incomplete-switch") @SuppressWarnings("incomplete-switch")