Improved battery and charger render
|
@ -6,6 +6,12 @@ import universalelectricity.core.net.Network;
|
|||
|
||||
public class EnergyDistributionNetwork extends Network<EnergyDistributionNetwork, TileEnergyDistribution>
|
||||
{
|
||||
public int getEnergyRenderForHeight()
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void redistribute(TileEnergyDistribution... exclusion)
|
||||
{
|
||||
long totalEnergy = 0;
|
||||
|
|
|
@ -5,19 +5,16 @@ package resonantinduction.electrical.battery;
|
|||
|
||||
import static org.lwjgl.opengl.GL11.glPopMatrix;
|
||||
import static org.lwjgl.opengl.GL11.glPushMatrix;
|
||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||
import static org.lwjgl.opengl.GL11.glScalef;
|
||||
import static org.lwjgl.opengl.GL11.glTranslatef;
|
||||
|
||||
import javax.naming.directory.DirContext;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.client.model.obj.WavefrontObject;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
@ -27,7 +24,6 @@ import resonantinduction.core.Reference;
|
|||
import universalelectricity.api.vector.Vector3;
|
||||
import calclavia.lib.render.RenderUtility;
|
||||
import calclavia.lib.render.item.ISimpleItemRenderer;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
|
@ -41,53 +37,111 @@ public class RenderBattery extends TileEntitySpecialRenderer implements ISimpleI
|
|||
public static RenderBattery INSTANCE = new RenderBattery();
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "battery/battery.tcn");
|
||||
|
||||
//Renders only if another battery on this side exists
|
||||
public static String[][] renderForSideOnly = new String[][] { new String[] { }, new String[] { }, new String[] { "frame1", "frame2" }, new String[] { "frame2", "frame3" }, new String[] { "frame3", "frame4" }, new String[] { "frame4", "frame5" } };
|
||||
|
||||
//Renders only if another battery on this side does NOT exist
|
||||
public static String[][] renderNotForSide = new String[][] { new String[] {"bottom", "coil1"}, new String[] { "top", "frame1con", "frame2con", "frame3con", "frame4con" }, new String[] { }, new String[] { }, new String[] { }, new String[] { } };
|
||||
|
||||
@Override
|
||||
public void renderInventoryItem(ItemStack itemStack)
|
||||
{
|
||||
glPushMatrix();
|
||||
GL11.glTranslated(0, 0, 0);
|
||||
int energyLevel = (int) (((double) ((ItemBlockBattery) itemStack.getItem()).getEnergy(itemStack) / (double) ((ItemBlockBattery) itemStack.getItem()).getEnergyCapacity(itemStack)) * 8);
|
||||
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery_" + energyLevel + ".png");
|
||||
MODEL.renderAllExcept("frame1con", "frame2con", "frame3con", "frame4con");
|
||||
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery.png");
|
||||
|
||||
List<String> disabledParts = new ArrayList<String>();
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "connector", "connectorIn", "connectorOut" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "frame1con", "frame2con", "frame3con", "frame4con" }));
|
||||
MODEL.renderAllExcept(disabledParts.toArray(new String[0]));
|
||||
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
if (i != 1 || !disabledParts.contains("coil1"))
|
||||
{
|
||||
if ((8 - i) <= energyLevel)
|
||||
MODEL.renderOnly("coil" + i + "lit");
|
||||
else
|
||||
MODEL.renderOnly("coil" + i);
|
||||
}
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f)
|
||||
{
|
||||
|
||||
renderForSideOnly = new String[][] { new String[] { "frame1con", "frame2con", "frame3con", "frame4con" }, new String[] { }, new String[] { }, new String[] { }, new String[] { }, new String[] { } };
|
||||
renderNotForSide = new String[][] { new String[] {"bottom", "coil1"}, new String[] { "top" }, new String[] { "frame1" }, new String[] { "frame3" }, new String[] { "frame2" }, new String[] { "frame4" } };
|
||||
|
||||
|
||||
String[][] partToDisable = new String[][] { new String[] {"bottom", "coil1"}, new String[] { "top","frame1con" ,"frame2con" ,"frame3con" ,"frame4con" }, new String[] { }, new String[] { }, new String[] { }, new String[] { } };
|
||||
String[][] partToDisable = new String[][] { new String[] { "bottom", "coil1" }, new String[] { "top" }, new String[] { "frame1", "frame2" }, new String[] { "frame3", "frame4" }, new String[] { "frame4", "frame1" }, new String[] { "frame2", "frame3" } };
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
|
||||
TileBattery tile = (TileBattery) t;
|
||||
|
||||
int energyLevel = (int) (((double) tile.energy.getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
|
||||
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery_" + energyLevel + ".png");
|
||||
int energyLevel = (int) Math.round(((double) tile.energy.getEnergy() / (double) TileBattery.getEnergyForTier(tile.getBlockMetadata())) * 8);
|
||||
RenderUtility.bind(Reference.DOMAIN, Reference.MODEL_PATH + "battery/battery.png");
|
||||
|
||||
List<String> disabledParts = new ArrayList<String>();
|
||||
List<String> enabledParts = new ArrayList<String>();
|
||||
|
||||
String[] disabledParts = new String[0];
|
||||
|
||||
for (ForgeDirection check : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (new Vector3(t).translate(check).getTileEntity(t.worldObj) instanceof TileBattery)
|
||||
{
|
||||
disabledParts = ArrayUtils.addAll(disabledParts, partToDisable[check.ordinal()]);
|
||||
disabledParts.addAll(Arrays.asList(partToDisable[check.ordinal()]));
|
||||
|
||||
if (check == ForgeDirection.UP)
|
||||
{
|
||||
enabledParts.addAll(Arrays.asList(partToDisable[check.ordinal()]));
|
||||
enabledParts.add("coil1");
|
||||
}
|
||||
else if (check == ForgeDirection.DOWN)
|
||||
{
|
||||
enabledParts.addAll(Arrays.asList(new String[] { "frame1con", "frame2con", "frame3con", "frame4con" }));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render IO interface.
|
||||
*/
|
||||
if (check.offsetY == 0)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
RenderUtility.rotateBlockBasedOnDirection(check);
|
||||
GL11.glRotatef(-90, 0, 1, 0);
|
||||
|
||||
int io = tile.getIO(check);
|
||||
|
||||
if (io == 1)
|
||||
{
|
||||
MODEL.renderOnly("connectorIn");
|
||||
}
|
||||
else if (io == 2)
|
||||
{
|
||||
MODEL.renderOnly("connectorOut");
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
MODEL.renderAllExcept(disabledParts);
|
||||
enabledParts.removeAll(disabledParts);
|
||||
|
||||
for (int i = 1; i <= 8; i++)
|
||||
{
|
||||
if (i != 1 || enabledParts.contains("coil1"))
|
||||
{
|
||||
if ((8 - i) <= energyLevel)
|
||||
MODEL.renderOnly("coil" + i + "lit");
|
||||
else
|
||||
MODEL.renderOnly("coil" + i);
|
||||
}
|
||||
}
|
||||
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "connector", "connectorIn", "connectorOut" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1", "coil2", "coil3", "coil4", "coil5", "coil6", "coil7", "coil8" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "coil1lit", "coil2lit", "coil3lit", "coil4lit", "coil5lit", "coil6lit", "coil7lit", "coil8lit" }));
|
||||
disabledParts.addAll(Arrays.asList(new String[] { "frame1con", "frame2con", "frame3con", "frame4con" }));
|
||||
MODEL.renderAllExcept(disabledParts.toArray(new String[0]));
|
||||
MODEL.renderOnly(enabledParts.toArray(new String[0]));
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
|
|||
public TileBattery()
|
||||
{
|
||||
this.energy = new EnergyStorageHandler(0);
|
||||
this.ioMap = 0;
|
||||
this.saveIOMap = true;
|
||||
}
|
||||
|
||||
|
@ -62,7 +63,8 @@ public class TileBattery extends TileEnergyDistribution implements IVoltageInput
|
|||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
//energy.setMaxTransfer((long) Math.min(Math.pow(10000, this.getNetwork().getConnectors().size()), energy.getEnergyCapacity()));
|
||||
// energy.setMaxTransfer((long) Math.min(Math.pow(10000,
|
||||
// this.getNetwork().getConnectors().size()), energy.getEnergyCapacity()));
|
||||
energy.setMaxTransfer(energy.getEnergyCapacity());
|
||||
markDistributionUpdate |= produce() > 0;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class RenderCharger implements ISimpleItemRenderer
|
|||
if (part.getStackInSlot(0) != null)
|
||||
{
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
RenderItemOverlayTile.renderItem(part.world(), part.placementSide, part.getStackInSlot(0), new Vector3(0.00, -0.4, -0.00), 0, 4);
|
||||
RenderItemOverlayTile.renderItem(part.world(), part.placementSide, part.getStackInSlot(0), new Vector3(0.00, -0.3, -0.00), 0, 4);
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
boolean isLooking = false;
|
||||
|
@ -64,7 +64,7 @@ public class RenderCharger implements ISimpleItemRenderer
|
|||
{
|
||||
long energy = CompatibilityModule.getEnergyItem(part.getStackInSlot(0));
|
||||
long maxEnergy = CompatibilityModule.getMaxEnergyItem(part.getStackInSlot(0));
|
||||
GL11.glTranslatef(0, 0.1F, 0);
|
||||
GL11.glTranslatef(0, 0.2F, 0);
|
||||
GL11.glRotatef(90, 1, 0, 0);
|
||||
RenderUtility.renderText(UnitDisplay.getDisplay(energy, Unit.JOULES, 2, true) + "/" + UnitDisplay.getDisplay(maxEnergy, Unit.JOULES, 2, true), 1, 1);
|
||||
}
|
||||
|
|
After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.3 KiB |