Added in rendering for LP for the Blood Altar.

This commit is contained in:
WayofTime 2016-01-03 23:16:43 -05:00
parent 10e29c56ba
commit 6ea5e8279f
2 changed files with 67 additions and 0 deletions

View file

@ -356,6 +356,7 @@ public class BloodAltar
fluidOutputted = Math.min(this.fluid.amount, fluidOutputted);
this.fluidOutput.amount += fluidOutputted;
this.fluid.amount -= fluidOutputted;
world.markBlockForUpdate(pos);
}
if (internalCounter % this.getChargingFrequency() == 0 && !this.isActive)
@ -364,6 +365,7 @@ public class BloodAltar
chargeInputted = Math.min(chargeInputted, maxCharge - totalCharge);
totalCharge += chargeInputted;
this.fluid.amount -= chargeInputted;
world.markBlockForUpdate(pos);
}
if (internalCounter % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0))

View file

@ -3,29 +3,94 @@ package WayofTime.bloodmagic.client.render;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import WayofTime.bloodmagic.block.BlockLifeEssence;
import WayofTime.bloodmagic.tile.TileAltar;
public class RenderAltar extends TileEntitySpecialRenderer<TileAltar>
{
public static Minecraft mc = Minecraft.getMinecraft();
public static ResourceLocation resource = new ResourceLocation("bloodmagic", "textures/blocks/lifeEssenceStill.png");
public static float minHeight = 0.6497f;
public static float maxHeight = 0.79f;
@Override
public void renderTileEntityAt(TileAltar tileAltar, double x, double y, double z, float partialTicks, int destroyStage)
{
ItemStack inputStack = tileAltar.getStackInSlot(0);
float level = ((float) tileAltar.getCurrentBlood()) / (float) tileAltar.getCapacity();
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
this.renderFluid(getWorld(), level);
this.renderItem(tileAltar.getWorld(), inputStack, partialTicks);
GlStateManager.popMatrix();
}
private void renderFluid(World world, float fluidLevel)
{
GlStateManager.pushMatrix();
Fluid fluid = BlockLifeEssence.getLifeEssence();
FluidStack fluidStack = new FluidStack(fluid, 1000);
GlStateManager.translate(0.5, minHeight + (fluidLevel) * (maxHeight - minHeight), 0.5);
Tessellator tessellator = Tessellator.getInstance();
WorldRenderer wr = tessellator.getWorldRenderer();
float size = 0.8f;
TextureAtlasSprite fluidStillSprite = Minecraft.getMinecraft().getTextureMapBlocks().getTextureExtry(fluid.getStill().toString());
int fluidColor = fluid.getColor(fluidStack);
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
setGLColorFromInt(fluidColor);
double uMin = (double) fluidStillSprite.getMinU();
double uMax = (double) fluidStillSprite.getMaxU();
double vMin = (double) fluidStillSprite.getMinV();
double vMax = (double) fluidStillSprite.getMaxV();
double var31 = uMin;
double var33 = uMax;
double var35 = vMin;
double var37 = vMax;
wr.begin(7, DefaultVertexFormats.POSITION_TEX);
// wr.setBrightness(200);
wr.pos(size / 2f, 0, size / 2f).tex(var33, var37).endVertex();
wr.pos(size / 2f, 0, -size / 2f).tex(var33, var35).endVertex();
wr.pos(-size / 2f, 0, -size / 2f).tex(var31, var35).endVertex();
wr.pos(-size / 2f, 0, size / 2f).tex(var31, var37).endVertex();
tessellator.draw();
GlStateManager.popMatrix();
}
private static void setGLColorFromInt(int color)
{
float red = (color >> 16 & 0xFF) / 255.0F;
float green = (color >> 8 & 0xFF) / 255.0F;
float blue = (color & 0xFF) / 255.0F;
GlStateManager.color(red, green, blue, 1.0F);
}
private void renderItem(World world, ItemStack stack, float partialTicks)
{
RenderItem itemRenderer = mc.getRenderItem();