BloodMagic/src/main/java/WayofTime/alchemicalWizardry/common/renderer/model/ModelBloodAltar.java

77 lines
3.1 KiB
Java
Raw Normal View History

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;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.client.FMLClientHandler;
2014-11-14 21:04:54 -02:00
import org.lwjgl.opengl.GL11;
2014-11-14 21:04:54 -02:00
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
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");
2015-07-30 08:44:01 -04:00
// private IModelCustom modelBloodAltar;
public ModelBloodAltar()
{
2015-07-30 08:44:01 -04:00
// modelBloodAltar = AdvancedModelLoader.loadModel(new ResourceLocation("alchemicalwizardry:models/bloodaltar-fixeUV.obj"));
}
public void renderBloodAltar()
{
2015-07-30 08:44:01 -04:00
// 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);
// 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());
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();
}
}