Added small battery energy loss and multimeter tweaks

This commit is contained in:
Calclavia 2014-01-29 12:16:54 +08:00
parent ce3feb0e67
commit 4887997646
6 changed files with 21 additions and 17 deletions

View file

@ -17,6 +17,13 @@ public class BatteryNetwork extends Network<BatteryNetwork, TileBattery>
totalCapacity += battery.energy.getEnergyCapacity();
}
/**
* Apply energy loss.
*/
double percentageLoss = Math.max(0, (1 - ((double) (getConnectors().size() * 6) / 100d)));
long energyLoss = (long) (percentageLoss * 10);
totalEnergy -= energyLoss;
int amountOfNodes = this.getConnectors().size() - exclusion.length;
if (totalEnergy > 0 && amountOfNodes > 0)

View file

@ -89,7 +89,7 @@ public class TileBattery extends TileElectrical implements IConnector<BatteryNet
if (!this.worldObj.isRemote)
{
long produce = this.produce();
if ((markDistributionUpdate || produce > 0) && ticks % 5 == 0)
{
this.getNetwork().redistribute();

View file

@ -88,12 +88,6 @@ public class GuiMultimeter extends GuiContainerBase
protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
{
super.drawGuiContainerBackgroundLayer(f, x, y);
/*
* int length = Math.min((int) (this.multimeter.getDetectedEnergy() /
* this.multimeter.getPeak()) * 115, 115);
* this.drawTexturedModalRect(this.containerWidth + 14, this.containerHeight + 126 - length,
* 176, 115 - length, 6, length);
*/
}
@Override

View file

@ -31,6 +31,9 @@ public class ItemMultimeter extends ItemMultipartBase
@Override
public TMultiPart newPart(ItemStack itemStack, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 hit)
{
/**
* If we're clicking on the multipart
*/
if (world.getBlockTileEntity(pos.x, pos.y, pos.z) instanceof TileMultipart && !ControlKeyModifer.isControlDown(player))
{
pos.offset(side ^ 1, -1);
@ -42,7 +45,7 @@ public class ItemMultimeter extends ItemMultipartBase
{
part.preparePlacement(side, itemStack.getItemDamage());
}
System.out.println("OFFSET"+pos);
return part;
}
@ -67,7 +70,7 @@ public class ItemMultimeter extends ItemMultipartBase
@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
if (!par2EntityPlayer.isSneaking())
if (par2EntityPlayer.isSneaking())
{
if (!world.isRemote)
{

View file

@ -33,17 +33,17 @@ import cpw.mods.fml.relauncher.SideOnly;
public class PartTransformer extends JCuboidPart implements JNormalOcclusion, TFacePart, IVoltageOutput, IEnergyInterface
{
public static Cuboid6[][] oBoxes = new Cuboid6[6][2];
public static Cuboid6[][] bounds = new Cuboid6[6][2];
static
{
oBoxes[0][0] = new Cuboid6(1 / 8D, 0, 0, 7 / 8D, 1 / 8D, 1);
oBoxes[0][1] = new Cuboid6(0, 0, 1 / 8D, 1, 1 / 8D, 7 / 8D);
bounds[0][0] = new Cuboid6(1 / 8D, 0, 0, 7 / 8D, 1 / 8D, 1);
bounds[0][1] = new Cuboid6(0, 0, 1 / 8D, 1, 1 / 8D, 7 / 8D);
for (int s = 1; s < 6; s++)
{
Transformation t = Rotation.sideRotations[s].at(Vector3.center);
oBoxes[s][0] = oBoxes[0][0].copy().apply(t);
oBoxes[s][1] = oBoxes[0][1].copy().apply(t);
bounds[s][0] = bounds[0][0].copy().apply(t);
bounds[s][1] = bounds[0][1].copy().apply(t);
}
}
@ -114,7 +114,7 @@ public class PartTransformer extends JCuboidPart implements JNormalOcclusion, TF
@Override
public Iterable<Cuboid6> getOcclusionBoxes()
{
return Arrays.asList(oBoxes[this.placementSide.ordinal()]);
return Arrays.asList(bounds[this.placementSide.ordinal()]);
}
protected ItemStack getItem()

View file

@ -62,8 +62,8 @@ public abstract class PartMechanical extends JCuboidPart implements JNormalOcclu
if (!world().isRemote)
{
System.out.println(this + ":" + getNetwork());
for (Object obj : connections)
System.out.println(obj);
/*for (Object obj : connections)
System.out.println(obj);*/
}
return false;