mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Finished implementing Induction Matrix core functionality, just about everything works! Need to redesign GUI to include separate gauge for output rate
This commit is contained in:
1 parent
2ed43e5328
commit
9260414177
22 files changed
+273
-142
No files matched your search
@@ -1,13 +1,19 @@
|
||||
package mekanism.common.tile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.content.matrix.MatrixUpdateProtocol;
|
||||
import mekanism.common.content.matrix.SynchronizedMatrixData;
|
||||
import mekanism.common.multiblock.MultiblockManager;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TileEntityInductionCasing extends TileEntityMultiblock<SynchronizedMatrixData>
|
||||
public class TileEntityInductionCasing extends TileEntityMultiblock<SynchronizedMatrixData> implements IStrictEnergyStorage
|
||||
{
|
||||
public TileEntityInductionCasing()
|
||||
{
|
||||
@@ -19,6 +25,54 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
|
||||
super(name);
|
||||
inventory = new ItemStack[2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(structure != null && isRendering)
|
||||
{
|
||||
structure.lastOutput = structure.outputCap-structure.remainingOutput;
|
||||
structure.remainingOutput = structure.outputCap;
|
||||
|
||||
ChargeUtils.charge(0, this);
|
||||
ChargeUtils.discharge(1, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList getNetworkedData(ArrayList data)
|
||||
{
|
||||
super.getNetworkedData(data);
|
||||
|
||||
if(structure != null)
|
||||
{
|
||||
data.add(structure.electricityStored);
|
||||
data.add(structure.storageCap);
|
||||
data.add(structure.outputCap);
|
||||
data.add(structure.lastOutput);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream)
|
||||
{
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
if(clientHasStructure)
|
||||
{
|
||||
structure.electricityStored = dataStream.readDouble();
|
||||
structure.storageCap = dataStream.readDouble();
|
||||
structure.outputCap = dataStream.readDouble();
|
||||
structure.lastOutput = dataStream.readDouble();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SynchronizedMatrixData getNewStructure()
|
||||
@@ -43,4 +97,31 @@ public class TileEntityInductionCasing extends TileEntityMultiblock<Synchronized
|
||||
{
|
||||
return MekanismUtils.localize("gui.inductionMatrix");
|
||||
}
|
||||
|
||||
public int getScaledEnergyLevel(int i)
|
||||
{
|
||||
return (int)(getEnergy()*i / getMaxEnergy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEnergy()
|
||||
{
|
||||
return structure != null ? structure.electricityStored : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy)
|
||||
{
|
||||
if(structure != null)
|
||||
{
|
||||
structure.electricityStored = Math.max(Math.min(energy, getMaxEnergy()), 0);
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy()
|
||||
{
|
||||
return structure != null ? structure.storageCap : 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user