Skip to content

Instantly share code, notes, and snippets.

@izzyaxel
Created August 19, 2015 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save izzyaxel/69cb6e047712a9feae37 to your computer and use it in GitHub Desktop.
Save izzyaxel/69cb6e047712a9feae37 to your computer and use it in GitHub Desktop.
public class EssenceCrystallizerTESR extends TileEntitySpecialRenderer
{
//Base
private IModelCustom crystallizerBase = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.MODID, "models/crystallizerBase.obj"));
private ResourceLocation crystallizerBaseTexture = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerBase.png");
//Bell
private IModelCustom crystallizerBell = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.MODID, "models/crystallizerBell.obj"));
private ResourceLocation crystallizerBellTexture = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerBell.png");
//Crystals
private IModelCustom crystal1 = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.MODID, "models/crystallizerCrystal1.obj"));
private IModelCustom crystal2 = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.MODID, "models/crystallizerCrystal2.obj"));
private IModelCustom crystal3 = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.MODID, "models/crystallizerCrystal3.obj"));
private IModelCustom crystal4 = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.MODID, "models/crystallizerCrystal4.obj"));
private ResourceLocation crystalTexture1 = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerCrystal1.png");
private ResourceLocation crystalTexture2 = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerCrystal2.png");
private ResourceLocation crystalTexture3 = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerCrystal3.png");
private ResourceLocation crystalTexture4 = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerCrystal4.png");
//Liquids
private IModelCustom crystallizerLiquid = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.MODID, "models/crystallizerLiquid.obj"));
private ResourceLocation crystallizerLiquidTextureRed = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerLiquidRed.png");
private ResourceLocation crystallizerLiquidTextureBlue = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerLiquidBlue.png");
private ResourceLocation crystallizerLiquidTextureGreen = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerLiquidGreen.png");
private ResourceLocation crystallizerLiquidTextureWhite = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerLiquidWhite.png");
private ResourceLocation crystallizerLiquidTextureBlack = new ResourceLocation(Reference.MODID, "textures/blocks/crystallizerLiquidBlack.png");
public void renderBell(float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.3f);
this.bindTexture(this.crystallizerBellTexture);
this.crystallizerBell.renderAll();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glPopMatrix();
}
public void renderLiquid(TileEntity tileEntity, float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if(tileEntity instanceof TEEssenceCrystallizer)
{
TEEssenceCrystallizer crystallizer = (TEEssenceCrystallizer)tileEntity;
if(crystallizer.hasItem())
{
float divisor = 2f;
if(crystallizer.getContents().getItem().equals(AAItems.fireEssence))
{
this.bindTexture(this.crystallizerLiquidTextureRed);
GL11.glColor4f(1.0f, 0.0f, 0.0f, 0.7f);
GL11.glTranslatef(x, y + 0.125f, z);
GL11.glScalef(1, 1 - Math.min(1, (float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS), 1);
GL11.glTranslatef(0, -(Math.min(1, ((float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS) / divisor)), 0);
this.crystallizerLiquid.renderAll();
}
else if(crystallizer.getContents().getItem().equals(AAItems.waterEssence))
{
this.bindTexture(this.crystallizerLiquidTextureBlue);
GL11.glColor4f(0.0f, 0.0f, 1.0f, 0.7f);
GL11.glTranslatef(x, y + 0.125f, z);
GL11.glScalef(1, 1 - Math.min(1, (float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS), 1);
GL11.glTranslatef(0, -(Math.min(1, ((float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS) / divisor)), 0);
this.crystallizerLiquid.renderAll();
}
else if(crystallizer.getContents().getItem().equals(AAItems.earthEssence))
{
this.bindTexture(this.crystallizerLiquidTextureGreen);
GL11.glColor4f(0.0f, 1.0f, 0.0f, 0.7f);
GL11.glTranslatef(x, y + 0.125f, z);
GL11.glScalef(1, 1 - Math.min(1, (float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS), 1);
GL11.glTranslatef(0, -(Math.min(1, ((float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS) / divisor)), 0);
this.crystallizerLiquid.renderAll();
}
else if(crystallizer.getContents().getItem().equals(AAItems.lightEssence))
{
this.bindTexture(this.crystallizerLiquidTextureWhite);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.7f);
GL11.glTranslatef(x, y + 0.125f, z);
GL11.glScalef(1, 1 - Math.min(1, (float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS), 1);
GL11.glTranslatef(0, -(Math.min(1, ((float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS) / divisor)), 0);
this.crystallizerLiquid.renderAll();
}
else if(crystallizer.getContents().getItem().equals(AAItems.darkEssence))
{
this.bindTexture(this.crystallizerLiquidTextureBlack);
GL11.glColor4d(0.0f, 0.0f, 0.0f, 0.7f);
GL11.glTranslatef(x, y + 0.125f, z);
GL11.glScalef(1, 1 - Math.min(1, (float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS), 1);
GL11.glTranslatef(0, -(Math.min(1, ((float) crystallizer.getCrystallizationProgress() / Reference.CRYSTALLIZERMAXWORKTICKS) / divisor)), 0);
this.crystallizerLiquid.renderAll();
}
}
}
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
public void renderCrystal(TileEntity tileEntity, float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
if(tileEntity instanceof TEEssenceCrystallizer)
{
TEEssenceCrystallizer crystallizer = (TEEssenceCrystallizer)tileEntity;
if(crystallizer.getCrystallizationProgress() < Reference.CRYSTALLIZERMAXWORKTICKS / 3 && crystallizer.getCrystallizationProgress() > Reference.CRYSTALLIZERMAXWORKTICKS / 6)
{
//model1
this.bindTexture(this.crystalTexture1);
this.crystal1.renderAll();
}
else if(crystallizer.getCrystallizationProgress() < Reference.CRYSTALLIZERMAXWORKTICKS / 1.5 && crystallizer.getCrystallizationProgress() > Reference.CRYSTALLIZERMAXWORKTICKS / 6)
{
//model2
this.bindTexture(this.crystalTexture2);
this.crystal2.renderAll();
}
else if(crystallizer.getCrystallizationProgress() < Reference.CRYSTALLIZERMAXWORKTICKS - 1 && crystallizer.getCrystallizationProgress() > Reference.CRYSTALLIZERMAXWORKTICKS / 6)
{
//model3
this.bindTexture(this.crystalTexture3);
this.crystal3.renderAll();
}
else if(crystallizer.isFinished())
{
//model4
this.bindTexture(this.crystalTexture4);
this.crystal4.renderAll();
}
}
GL11.glPopMatrix();
}
public void renderBase(float x, float y, float z)
{
GL11.glPushMatrix();
GL11.glTranslatef(x, y, z);
this.bindTexture(this.crystallizerBaseTexture);
this.crystallizerBase.renderAll();
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double xPos, double yPos, double zPos, float idk)
{
float x = (float)xPos;
float y = (float)yPos;
float z = (float)zPos;
GL11.glPushMatrix();
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.renderCrystal(tileEntity, x, y, z);
this.renderBase(x, y, z);
this.renderLiquid(tileEntity, x, y, z);
this.renderBell(x, y, z);
GL11.glPopMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment