2014-06-27 19:43:09 -04:00
|
|
|
package WayofTime.alchemicalWizardry.common.renderer.model;
|
|
|
|
|
|
|
|
import net.minecraft.client.model.ModelBase;
|
2014-11-14 21:04:54 -02:00
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2015-07-29 08:23:01 -04:00
|
|
|
import net.minecraft.client.renderer.WorldRenderer;
|
|
|
|
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
2014-11-14 21:04:54 -02:00
|
|
|
import net.minecraft.client.renderer.texture.TextureMap;
|
2014-06-27 19:43:09 -04:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2015-07-29 08:59:13 -04:00
|
|
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
2014-11-14 21:04:54 -02:00
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
2014-11-14 21:04:54 -02:00
|
|
|
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
|
|
|
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
|
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
public class ModelBloodAltar extends ModelBase
|
|
|
|
{
|
2014-11-14 21:04:54 -02:00
|
|
|
private static final ResourceLocation altar_texture = new ResourceLocation("alchemicalwizardry:textures/models/altar.png");
|
|
|
|
|
2014-06-27 19:43:09 -04:00
|
|
|
private IModelCustom modelBloodAltar;
|
|
|
|
|
|
|
|
public ModelBloodAltar()
|
|
|
|
{
|
|
|
|
modelBloodAltar = AdvancedModelLoader.loadModel(new ResourceLocation("alchemicalwizardry:models/bloodaltar-fixeUV.obj"));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void renderBloodAltar()
|
|
|
|
{
|
|
|
|
modelBloodAltar.renderAll();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void renderBloodAltar(TEAltar altar, double x, double y, double z)
|
|
|
|
{
|
|
|
|
float scale = 0.1f;
|
|
|
|
// Push a blank matrix onto the stack
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
// Move the object into the correct position on the block (because the OBJ's origin is the center of the object)
|
|
|
|
GL11.glTranslatef((float) x + 0.5f, (float) y, (float) z + 0.5f);
|
|
|
|
// Scale our object to about half-size in all directions (the OBJ file is a little large)
|
|
|
|
GL11.glScalef(scale, scale, scale);
|
|
|
|
// Bind the texture, so that OpenGL properly textures our block.
|
2014-11-14 21:04:54 -02:00
|
|
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(altar_texture);
|
2014-06-27 19:43:09 -04:00
|
|
|
// Render the object, using modelTutBox.renderAll();
|
|
|
|
this.renderBloodAltar();
|
|
|
|
// Pop this matrix from the stack.
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void renderBloodLevel(TEAltar altar, double x, double y, double z)
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
float level = altar.getFluidAmount();
|
2014-11-14 21:04:54 -02:00
|
|
|
GL11.glTranslatef((float) x , (float) y + 0.6499f + 0.12f * (level / altar.getCapacity()), (float) z);
|
|
|
|
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
|
|
|
renderBloodLevel(AlchemicalWizardry.lifeEssenceFluid.getStillIcon());
|
2014-06-27 19:43:09 -04:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2014-11-14 21:04:54 -02:00
|
|
|
|
2015-07-29 08:23:01 -04:00
|
|
|
public void renderBloodLevel(TextureAtlasSprite icon)
|
2014-11-14 21:04:54 -02:00
|
|
|
{
|
2015-07-29 08:23:01 -04:00
|
|
|
Tessellator tessellator = Tessellator.getInstance();
|
|
|
|
WorldRenderer wr = tessellator.getWorldRenderer();
|
2014-11-14 21:04:54 -02:00
|
|
|
|
|
|
|
double minU = (double) icon.getInterpolatedU(0);
|
|
|
|
double maxU = (double) icon.getInterpolatedU(16);
|
|
|
|
double minV = (double) icon.getInterpolatedV(0);
|
|
|
|
double maxV = (double) icon.getInterpolatedV(16);
|
|
|
|
|
2015-07-29 08:23:01 -04:00
|
|
|
wr.startDrawingQuads();
|
|
|
|
wr.func_178980_d(0, 1, 0); //setNormal
|
|
|
|
wr.addVertexWithUV(1, 0, 1, maxU, maxV);
|
|
|
|
wr.addVertexWithUV(1, 0, 0, maxU, minV);
|
|
|
|
wr.addVertexWithUV(0, 0, 0, minU, minV);
|
|
|
|
wr.addVertexWithUV(0, 0, 1, minU, maxV);
|
2014-11-14 21:04:54 -02:00
|
|
|
tessellator.draw();
|
|
|
|
}
|
|
|
|
}
|