2014-06-27 19:43:09 -04:00
|
|
|
package WayofTime.alchemicalWizardry.common.renderer.block;
|
|
|
|
|
2015-07-29 17:37:08 -04:00
|
|
|
import net.minecraft.client.Minecraft;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2015-07-29 15:04:00 -04:00
|
|
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2015-07-29 15:04:00 -04:00
|
|
|
import WayofTime.alchemicalWizardry.common.renderer.model.ModelPedestal;
|
|
|
|
import WayofTime.alchemicalWizardry.common.tileEntity.TEPedestal;
|
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
public class RenderPedestal extends TileEntitySpecialRenderer
|
|
|
|
{
|
|
|
|
private ModelPedestal modelPedestal = new ModelPedestal();
|
|
|
|
private final RenderItem customRenderItem;
|
|
|
|
|
|
|
|
public RenderPedestal()
|
|
|
|
{
|
2015-07-29 17:37:08 -04:00
|
|
|
customRenderItem = Minecraft.getMinecraft().getRenderItem();
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-29 17:37:08 -04:00
|
|
|
public void renderTileEntityAt(TileEntity tileEntity, double d0, double d1, double d2, float f, int i)
|
2014-06-27 19:43:09 -04:00
|
|
|
{
|
|
|
|
if (tileEntity instanceof TEPedestal)
|
|
|
|
{
|
|
|
|
TEPedestal tileAltar = (TEPedestal) tileEntity;
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
|
|
|
ResourceLocation test = new ResourceLocation("alchemicalwizardry:textures/models/Pedestal.png");
|
|
|
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(test);
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
2015-07-02 11:05:07 -04:00
|
|
|
this.modelPedestal.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
|
2014-06-27 19:43:09 -04:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
|
|
|
if (tileAltar.getStackInSlot(0) != null)
|
|
|
|
{
|
|
|
|
float scaleFactor = getGhostItemScaleFactor(tileAltar.getStackInSlot(0));
|
|
|
|
float rotationAngle = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);
|
2015-07-29 17:37:08 -04:00
|
|
|
EntityItem ghostEntityItem = new EntityItem(tileAltar.getWorld());
|
2014-06-27 19:43:09 -04:00
|
|
|
ghostEntityItem.hoverStart = 0.0F;
|
|
|
|
ghostEntityItem.setEntityItemStack(tileAltar.getStackInSlot(0));
|
|
|
|
float displacement = 0.2F;
|
|
|
|
|
|
|
|
if (ghostEntityItem.getEntityItem().getItem() instanceof ItemBlock)
|
|
|
|
{
|
|
|
|
GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.7F, (float) d2 + 0.5F);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + displacement + 0.6F, (float) d2 + 0.5F);
|
|
|
|
}
|
|
|
|
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
|
|
|
|
GL11.glRotatef(rotationAngle, 0.0F, 1.0F, 0.0F);
|
2015-07-29 17:37:08 -04:00
|
|
|
customRenderItem.func_175043_b(ghostEntityItem.getEntityItem()); //renderItemModel
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
2014-10-13 22:33:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glTranslatef((float) d0 + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
|
|
|
|
|
|
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(test);
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
GL11.glPopMatrix();
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private float getGhostItemScaleFactor(ItemStack itemStack)
|
|
|
|
{
|
|
|
|
float scaleFactor = 1.0F;
|
|
|
|
|
|
|
|
if (itemStack != null)
|
|
|
|
{
|
|
|
|
if (itemStack.getItem() instanceof ItemBlock)
|
|
|
|
{
|
2015-07-29 17:37:08 -04:00
|
|
|
return 0.9f;
|
2014-06-27 19:43:09 -04:00
|
|
|
} else
|
|
|
|
{
|
2015-07-29 17:37:08 -04:00
|
|
|
return 0.65f;
|
2014-06-27 19:43:09 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return scaleFactor;
|
|
|
|
}
|
|
|
|
}
|