Render Energy Core in Energy Cube Item's that have power
package mekanism.client.render.item;
import javax.annotation.Nonnull;
+import mekanism.client.MekanismClient;
import mekanism.client.model.ModelEnergyCube;
+import mekanism.client.model.ModelEnergyCube.ModelEnergyCore;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.tileentity.RenderEnergyCube;
import mekanism.common.SideData.IOState;
import mekanism.common.Tier.EnergyCubeTier;
import mekanism.common.base.ITierItem;
+import mekanism.common.util.ItemDataUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
@@ -14,11 +17,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderEnergyCubeItem extends MekanismItemStackRenderer {
private static ModelEnergyCube energyCube = new ModelEnergyCube();
+ private static ModelEnergyCore core = new ModelEnergyCore();
public static ItemLayerWrapper model;
@Override
@@ -43,6 +48,34 @@ public class RenderEnergyCubeItem extends MekanismItemStackRenderer {
MekanismRenderer.blendOff();
GlStateManager.popMatrix();
+
+ double energy = ItemDataUtils.getDouble(stack, "energyStored");
+
+ if (energy / tier.maxEnergy > 0.1) {
+ GlStateManager.pushMatrix();
+ MekanismRenderer.bindTexture(RenderEnergyCube.coreTexture);
+
+ MekanismRenderer.blendOn();
+ MekanismRenderer.glowOn();
+
+ int[] c = RenderEnergyCube.COLORS[tier.getBaseTier().ordinal()];
+
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(0.4F, 0.4F, 0.4F);
+ GL11.glColor4f((float) c[0] / 255F, (float) c[1] / 255F, (float) c[2] / 255F,
+ (float) (energy / tier.maxEnergy));
+ GlStateManager.translate(0, (float) Math.sin(Math.toRadians(MekanismClient.ticksPassed * 3)) / 7, 0);
+ GlStateManager.rotate(MekanismClient.ticksPassed * 4, 0, 1, 0);
+ GlStateManager.rotate(36F + MekanismClient.ticksPassed * 4, 0, 1, 1);
+ core.render(0.0625F);
+ MekanismRenderer.resetColor();
+ GlStateManager.popMatrix();
+
+ MekanismRenderer.glowOff();
+ MekanismRenderer.blendOff();
+
+ GlStateManager.popMatrix();
+ }
}
@Override
