Buses now render properly in Item Frames.

Fixed Issue with Storage Monitor Renders.
Fixed  a render glitch on formation/annihilation entity form.
This commit is contained in:
AlgorithmX2 2014-02-19 22:20:38 -06:00
parent 39fed650aa
commit 921c681b47
11 changed files with 138 additions and 81 deletions

View file

@ -1,18 +1,35 @@
package appeng.client; package appeng.client;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.particle.EntityFX; import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.opengl.GL11;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
import appeng.client.render.BaseBlockRender; import appeng.client.render.BaseBlockRender;
import appeng.client.render.TESRWrapper; import appeng.client.render.TESRWrapper;
@ -32,6 +49,89 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class ClientHelper extends ServerHelper public class ClientHelper extends ServerHelper
{ {
private static RenderItem itemRenderer = new RenderItem();
private static RenderBlocks blockRenderer = new RenderBlocks();
@Override
public void doRenderItem(ItemStack itemstack, TileEntity par1EntityItemFrame)
{
if ( itemstack != null )
{
EntityItem entityitem = new EntityItem( par1EntityItemFrame.getWorldObj(), 0.0D, 0.0D, 0.0D, itemstack );
entityitem.getEntityItem().stackSize = 1;
// set all this stuff and then do shit? meh?
entityitem.hoverStart = 0;
entityitem.age = 0;
entityitem.rotationYaw = 0;
GL11.glPushMatrix();
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
// GL11.glDisable( GL11.GL_CULL_FACE );
if ( itemstack.isItemEnchanted() )
{
GL11.glTranslatef( 0.0f, -0.05f, -0.25f );
GL11.glScalef( 1.0f / 1.5f, 1.0f / 1.5f, 1.0f / 1.5f );
// GL11.glTranslated( -8.0, -12.2, -10.6 );
GL11.glScalef( 1.0f, -1.0f, 0.005f );
// GL11.glScalef( 1.0f , -1.0f, 1.0f );
Block block = Block.getBlockFromItem( itemstack.getItem() );
if ( (itemstack.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d( block.getRenderType() )) )
{
GL11.glRotatef( 25.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( 15.0f, 0.0f, 1.0f, 0.0f );
GL11.glRotatef( 30.0f, 0.0f, 1.0f, 0.0f );
}
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer( itemstack, ENTITY );
if ( customRenderer != null && !(itemstack.getItem() instanceof ItemBlock) )
{
if ( customRenderer.shouldUseRenderHelper( ENTITY, itemstack, BLOCK_3D ) )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 0.7f, 0.7f, 0.7f );
GL11.glRotatef( 35, 1, 0, 0 );
GL11.glRotatef( 45, 0, 1, 0 );
GL11.glRotatef( -90, 0, 1, 0 );
}
}
else if ( itemstack.getItem() instanceof ItemBlock )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 1.1f, 1.1f, 1.1f );
GL11.glRotatef( -90, 0, 1, 0 );
}
else
{
GL11.glTranslatef( 0, -0.14F, 0 );
GL11.glScalef( 0.8f, 0.8f, 0.8f );
}
RenderItem.renderInFrame = true;
RenderManager.instance.renderEntityWithPosYaw( entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F );
RenderItem.renderInFrame = false;
}
else
{
GL11.glScalef( 1.0f / 42.0f, 1.0f / 42.0f, 1.0f / 42.0f );
GL11.glTranslated( -8.0, -10.2, -10.4 );
GL11.glScalef( 1.0f, 1.0f, 0.005f );
RenderItem.renderInFrame = false;
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
if ( !ForgeHooksClient.renderInventoryItem( blockRenderer, Minecraft.getMinecraft().renderEngine, itemstack, true, 0, (float) 0, (float) 0 ) )
{
itemRenderer.renderItemIntoGUI( fr, Minecraft.getMinecraft().renderEngine, itemstack, 0, 0, false );
}
}
GL11.glPopMatrix();
}
}
@Override @Override
public void init() public void init()
{ {

View file

@ -75,7 +75,13 @@ public class BusRenderer implements IItemRenderer
} }
if ( type == ItemRenderType.ENTITY ) if ( type == ItemRenderType.ENTITY )
GL11.glTranslatef( -0.5f, -0.5f, -0.5f ); {
GL11.glRotatef( 90.0f, 0.0f, 1.0f, 0.0f );
GL11.glScalef( 0.8f, 0.8f, 0.8f );
GL11.glTranslatef( -0.8f, -0.87f, -0.7f );
}
if ( type == ItemRenderType.INVENTORY ) if ( type == ItemRenderType.INVENTORY )
GL11.glTranslatef( 0.0f, -0.1f, 0.0f ); GL11.glTranslatef( 0.0f, -0.1f, 0.0f );
@ -115,6 +121,13 @@ public class BusRenderer implements IItemRenderer
else else
{ {
IPart ip = getRenderer( item, (IPartItem) item.getItem() ); IPart ip = getRenderer( item, (IPartItem) item.getItem() );
if ( type == ItemRenderType.ENTITY )
{
int depth = ip.cableConnectionRenderTo();
GL11.glTranslatef( 0.0f, 0.0f, -0.04f * (8 - depth) - 0.06f );
}
if ( ip != null ) if ( ip != null )
ip.renderInventory( BusRenderHelper.instance, renderer ); ip.renderInventory( BusRenderHelper.instance, renderer );
} }

View file

@ -4,6 +4,8 @@ import java.util.List;
import java.util.Random; import java.util.Random;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
@ -34,4 +36,6 @@ public abstract class CommonHelper
public abstract MovingObjectPosition getMOP(); public abstract MovingObjectPosition getMOP();
public abstract void doRenderItem(ItemStack sis, TileEntity tile);
} }

View file

@ -56,8 +56,9 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{ {
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); CableBusTextures.PartTransitionPlaneBack.getIcon(), is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 1, 1, 15, 15, 15, 16 ); rh.setBounds( 1, 1, 15, 15, 15, 16 );
rh.renderInventoryBox( renderer ); rh.renderInventoryBox( renderer );

View file

@ -123,8 +123,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{ {
rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorBack.getIcon(), rh.setTexture( CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon(),
is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(), CableBusTextures.PartMonitorSides.getIcon() ); CableBusTextures.PartTransitionPlaneBack.getIcon(), is.getIconIndex(), CableBusTextures.PartMonitorSides.getIcon(),
CableBusTextures.PartMonitorSides.getIcon() );
rh.setBounds( 1, 1, 15, 15, 15, 16 ); rh.setBounds( 1, 1, 15, 15, 15, 16 );
rh.renderInventoryBox( renderer ); rh.renderInventoryBox( renderer );

View file

@ -360,7 +360,7 @@ public class PartCable extends AEBasePart implements IPartCable
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{ {
GL11.glTranslated( -0.2, -0.3, 0.0 ); GL11.glTranslated( -0.0, -0.0, 0.3 );
rh.setTexture( getTexture( getCableColor() ) ); rh.setTexture( getTexture( getCableColor() ) );
rh.setBounds( 6.0f, 6.0f, 2.0f, 10.0f, 10.0f, 14.0f ); rh.setBounds( 6.0f, 6.0f, 2.0f, 10.0f, 10.0f, 14.0f );

View file

@ -102,7 +102,7 @@ public class PartCableCovered extends PartCable
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{ {
GL11.glTranslated( -0.2, -0.3, 0.0 ); GL11.glTranslated( -0.0, -0.0, 0.3 );
rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f ); rh.setBounds( 5.0f, 5.0f, 2.0f, 11.0f, 11.0f, 14.0f );
float offu = 0; float offu = 0;

View file

@ -64,7 +64,7 @@ public class PartCableSmart extends PartCable
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{ {
GL11.glTranslated( -0.2, -0.3, 0.0 ); GL11.glTranslated( -0.0, -0.0, 0.3 );
float offu = 0; float offu = 0;
float offv = 9; float offv = 9;

View file

@ -78,7 +78,7 @@ public class PartDenseCable extends PartCable
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer) public void renderInventory(IPartRenderHelper rh, RenderBlocks renderer)
{ {
GL11.glTranslated( -0.2, -0.3, 0.0 ); GL11.glTranslated( -0.0, -0.0, 0.3 );
rh.setBounds( 4.0f, 4.0f, 2.0f, 12.0f, 12.0f, 14.0f ); rh.setBounds( 4.0f, 4.0f, 2.0f, 12.0f, 12.0f, 14.0f );
float offu = 0; float offu = 0;

View file

@ -1,29 +1,20 @@
package appeng.parts.reporting; package appeng.parts.reporting;
import static net.minecraftforge.client.IItemRenderer.ItemRenderType.ENTITY;
import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.io.IOException; import java.io.IOException;
import net.minecraft.block.Block;
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.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
@ -39,6 +30,7 @@ import appeng.api.storage.StorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.client.ClientHelper;
import appeng.client.texture.CableBusTextures; import appeng.client.texture.CableBusTextures;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
@ -238,20 +230,6 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
ItemStack sis = ais.getItemStack(); ItemStack sis = ais.getItemStack();
sis.stackSize = 1; sis.stackSize = 1;
GL11.glTranslatef( 0.0f, -0.05f, -0.25f );
GL11.glScalef( 1.0f / 1.5f, 1.0f / 1.5f, 1.0f / 1.5f );
// GL11.glTranslated( -8.0, -12.2, -10.6 );
GL11.glScalef( 1.0f, -1.0f, 0.005f );
// GL11.glScalef( 1.0f , -1.0f, 1.0f );
Block block = Block.getBlockFromItem( sis.getItem() );
if ( (sis.getItemSpriteNumber() == 0 && block != null && RenderBlocks.renderItemIn3d( block.getRenderType() )) )
{
GL11.glRotatef( 25.0f, 1.0f, 0.0f, 0.0f );
GL11.glRotatef( 15.0f, 0.0f, 1.0f, 0.0f );
GL11.glRotatef( 30.0f, 0.0f, 1.0f, 0.0f );
}
int br = 16 << 20 | 16 << 4; int br = 16 << 20 | 16 << 4;
int var11 = br % 65536; int var11 = br % 65536;
int var12 = br / 65536; int var12 = br / 65536;
@ -264,7 +242,7 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
// RenderHelper.enableGUIStandardItemLighting(); // RenderHelper.enableGUIStandardItemLighting();
tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f ); tess.setColorOpaque_F( 1.0f, 1.0f, 1.0f );
doRenderItem( sis, this.tile ); ClientHelper.proxy.doRenderItem( sis, this.tile );
} }
catch (Exception e) catch (Exception e)
@ -299,54 +277,6 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit
} }
} }
private void doRenderItem(ItemStack itemstack, TileEntity par1EntityItemFrame)
{
if ( itemstack != null )
{
EntityItem entityitem = new EntityItem( par1EntityItemFrame.getWorldObj(), 0.0D, 0.0D, 0.0D, itemstack );
entityitem.getEntityItem().stackSize = 1;
// set all this stuff and then do shit? meh?
entityitem.hoverStart = 0;
entityitem.age = 0;
entityitem.rotationYaw = 0;
GL11.glPushMatrix();
GL11.glTranslatef( 0, -0.04F, 0 );
// GL11.glDisable( GL11.GL_CULL_FACE );
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer( itemstack, ENTITY );
if ( customRenderer != null && !(itemstack.getItem() instanceof ItemBlock) )
{
if ( customRenderer.shouldUseRenderHelper( ENTITY, itemstack, BLOCK_3D ) )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 0.7f, 0.7f, 0.7f );
GL11.glRotatef( 35, 1, 0, 0 );
GL11.glRotatef( 45, 0, 1, 0 );
GL11.glRotatef( -90, 0, 1, 0 );
}
}
else if ( itemstack.getItem() instanceof ItemBlock )
{
GL11.glTranslatef( 0, -0.04F, 0 );
GL11.glScalef( 1.1f, 1.1f, 1.1f );
GL11.glRotatef( -90, 0, 1, 0 );
}
else
{
GL11.glTranslatef( 0, -0.14F, 0 );
GL11.glScalef( 0.8f, 0.8f, 0.8f );
}
RenderItem.renderInFrame = false;
RenderManager.instance.renderEntityWithPosYaw( entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F );
RenderItem.renderInFrame = false;
GL11.glPopMatrix();
}
}
@Override @Override
public IAEStack getDisplayed() public IAEStack getDisplayed()
{ {

View file

@ -6,7 +6,9 @@ import java.util.Random;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.block.AEBaseBlock; import appeng.block.AEBaseBlock;
@ -19,6 +21,12 @@ import cpw.mods.fml.common.FMLCommonHandler;
public class ServerHelper extends CommonHelper public class ServerHelper extends CommonHelper
{ {
@Override
public void doRenderItem(ItemStack sis, TileEntity tile)
{
}
@Override @Override
public List<EntityPlayer> getPlayers() public List<EntityPlayer> getPlayers()
{ {