mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-23 21:39:40 +00:00
Add RedstoneControl to Electric Pump.
This commit is contained in:
1 parent
ee585c05dc
commit
e14501f3b5
2 files changed
+38
-4
No files matched your search
@@ -39,6 +39,7 @@ public class GuiElectricPump extends GuiMekanism
|
||||
return tileEntity.fluidTank;
|
||||
}
|
||||
}, GuiGauge.Type.STANDARD, this, guiLocation, 6, 13));
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
@@ -36,7 +37,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable
|
||||
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable, IRedstoneControl
|
||||
{
|
||||
/** This pump's tank */
|
||||
public FluidTank fluidTank = new FluidTank(10000);
|
||||
@@ -44,6 +45,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
/** The nodes that have full sources near them or in them */
|
||||
public Set<Coord4D> recurringNodes = new HashSet<Coord4D>();
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
public TileEntityElectricPump()
|
||||
{
|
||||
super("ElectricPump", 10000);
|
||||
@@ -118,11 +122,18 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
}
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote && worldObj.getWorldTime() % 20 == 0)
|
||||
if(!worldObj.isRemote && ticker % 20 == 0)
|
||||
{
|
||||
if(getEnergy() >= Mekanism.electricPumpUsage && (fluidTank.getFluid() == null || fluidTank.getFluid().amount+FluidContainerRegistry.BUCKET_VOLUME <= fluidTank.getCapacity()))
|
||||
if(MekanismUtils.canFunction(this))
|
||||
{
|
||||
suck(true);
|
||||
if(getEnergy() >= Mekanism.electricPumpUsage && (fluidTank.getFluid() == null || fluidTank.getFluid().amount + FluidContainerRegistry.BUCKET_VOLUME <= fluidTank.getCapacity()))
|
||||
{
|
||||
suck(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ticker--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +248,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
else {
|
||||
fluidTank.setFluid(null);
|
||||
}
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
|
||||
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
@@ -255,6 +267,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
else {
|
||||
data.add(0);
|
||||
}
|
||||
data.add(controlType.ordinal());
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -274,6 +287,8 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
|
||||
NBTTagList recurringList = new NBTTagList();
|
||||
|
||||
for(Coord4D wrapper : recurringNodes)
|
||||
@@ -299,6 +314,11 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
|
||||
}
|
||||
|
||||
if(nbtTags.hasKey("controlType"))
|
||||
{
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
}
|
||||
|
||||
if(nbtTags.hasKey("recurringNodes"))
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("recurringNodes", NBT.TAG_COMPOUND);
|
||||
@@ -456,4 +476,17 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
return controlType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setControlType(RedstoneControl type)
|
||||
{
|
||||
controlType = type;
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user