Added framework for restricted EIM input, improved & cleaned up CC integration

This commit is contained in:
aidancbrady 2015-07-06 13:38:08 -07:00
parent 1edec150c6
commit b01f31a65e
4 changed files with 27 additions and 22 deletions

View file

@ -48,7 +48,7 @@ public class GuiMatrixStats extends GuiMekanism
@Override @Override
public double getLevel() public double getLevel()
{ {
return tileEntity.structure.lastOutput/tileEntity.structure.outputCap; return tileEntity.structure.lastOutput/tileEntity.structure.transferCap;
} }
}, MekanismUtils.getResource(ResourceType.GUI, "GuiMatrixStats.png"), 30, 13)); }, MekanismUtils.getResource(ResourceType.GUI, "GuiMatrixStats.png"), 30, 13));
} }
@ -65,7 +65,7 @@ public class GuiMatrixStats extends GuiMekanism
fontRendererObj.drawString(LangUtils.localize("gui.energy") + ":", 53, 26, 0x797979); fontRendererObj.drawString(LangUtils.localize("gui.energy") + ":", 53, 26, 0x797979);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()), 59, 35, 0x404040); fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()), 59, 35, 0x404040);
fontRendererObj.drawString(LangUtils.localize("gui.output") + ":", 53, 46, 0x797979); fontRendererObj.drawString(LangUtils.localize("gui.output") + ":", 53, 46, 0x797979);
fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.outputCap), 59, 55, 0x404040); fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), 59, 55, 0x404040);
fontRendererObj.drawString(LangUtils.localize("gui.dimensions") + ":", 8, 82, 0x797979); fontRendererObj.drawString(LangUtils.localize("gui.dimensions") + ":", 8, 82, 0x797979);
fontRendererObj.drawString(tileEntity.structure.volWidth + " x " + tileEntity.structure.volHeight + " x " + tileEntity.structure.volLength, 14, 91, 0x404040); fontRendererObj.drawString(tileEntity.structure.volWidth + " x " + tileEntity.structure.volHeight + " x " + tileEntity.structure.volLength, 14, 91, 0x404040);

View file

@ -87,7 +87,7 @@ public class MatrixUpdateProtocol extends UpdateProtocol<SynchronizedMatrixData>
else if(tile instanceof TileEntityInductionProvider) else if(tile instanceof TileEntityInductionProvider)
{ {
structureFound.providers.add(coord); structureFound.providers.add(coord);
structureFound.outputCap += ((TileEntityInductionProvider)tile).tier.output; structureFound.transferCap += ((TileEntityInductionProvider)tile).tier.output;
} }
} }
} }

View file

@ -18,12 +18,15 @@ public class SynchronizedMatrixData extends SynchronizedData<SynchronizedMatrixD
public Set<Coord4D> providers = new HashSet<Coord4D>(); public Set<Coord4D> providers = new HashSet<Coord4D>();
public double remainingInput;
public double lastInput;
public double remainingOutput; public double remainingOutput;
public double lastOutput; public double lastOutput;
public double clientEnergy; public double clientEnergy;
public double storageCap; public double storageCap;
public double outputCap; public double transferCap;
@Override @Override
public ItemStack[] getInventory() public ItemStack[] getInventory()

View file

@ -48,8 +48,11 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
{ {
if(structure != null && isRendering) if(structure != null && isRendering)
{ {
structure.lastOutput = structure.outputCap-structure.remainingOutput; structure.lastInput = structure.transferCap-structure.remainingInput;
structure.remainingOutput = structure.outputCap; structure.remainingInput = structure.transferCap;
structure.lastOutput = structure.transferCap-structure.remainingOutput;
structure.remainingOutput = structure.transferCap;
ChargeUtils.charge(0, this); ChargeUtils.charge(0, this);
ChargeUtils.discharge(1, this); ChargeUtils.discharge(1, this);
@ -66,7 +69,8 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
{ {
data.add(structure.getEnergy(worldObj)); data.add(structure.getEnergy(worldObj));
data.add(structure.storageCap); data.add(structure.storageCap);
data.add(structure.outputCap); data.add(structure.transferCap);
data.add(structure.lastInput);
data.add(structure.lastOutput); data.add(structure.lastOutput);
data.add(structure.volWidth); data.add(structure.volWidth);
@ -89,7 +93,8 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
{ {
structure.clientEnergy = dataStream.readDouble(); structure.clientEnergy = dataStream.readDouble();
structure.storageCap = dataStream.readDouble(); structure.storageCap = dataStream.readDouble();
structure.outputCap = dataStream.readDouble(); structure.transferCap = dataStream.readDouble();
structure.lastInput = dataStream.readDouble();
structure.lastOutput = dataStream.readDouble(); structure.lastOutput = dataStream.readDouble();
structure.volWidth = dataStream.readInt(); structure.volWidth = dataStream.readInt();
@ -168,10 +173,10 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
@Method(modid = "ComputerCraft") @Method(modid = "ComputerCraft")
public String getType() public String getType()
{ {
return "Mekanism-InductionMatrix"; return "InductionMatrix";
} }
public static final String[] NAMES = new String[] { "getEnergyStored", "getMaxEnergyStored", "getEnergyStoredMJ", "getMaxEnergyStoredMJ", "getLastOutput", "getOutputCap" }; public static final String[] NAMES = new String[] {"getStored", "getMaxEnergy", "getLastInput", "getLastOutput", "getTransferCap"};
@Override @Override
@Method(modid = "ComputerCraft") @Method(modid = "ComputerCraft")
@ -184,28 +189,25 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
@Method(modid = "ComputerCraft") @Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{ {
if (structure == null) if(structure == null)
{ {
return new Object[] { "Unformed." }; return new Object[] {"Unformed."};
} }
switch (method) switch(method)
{ {
case 0: case 0:
return new Object[] { getEnergy() * general.TO_TE }; return new Object[] {getEnergy()};
case 1: case 1:
return new Object[] { getMaxEnergy() * general.TO_TE }; return new Object[] {getMaxEnergy()};
case 2: case 2:
return new Object[] { getEnergy() }; return new Object[] {structure.lastInput};
case 3: case 3:
return new Object[] { getMaxEnergy() }; return new Object[] {structure.lastOutput};
case 4: case 4:
return new Object[] { structure.lastOutput }; return new Object[] {structure.transferCap};
case 5:
return new Object[] { structure.outputCap };
default: default:
Mekanism.logger.error("Attempted to call unknown method with computer ID " + computer.getID()); return new Object[] {"Unknown command."};
return new Object[] { "Unknown command." };
} }
} }