Electric Pump and Fluidic Plenisher now have CC support for resetting their calculations

This commit is contained in:
Aidan C. Brady 2015-03-28 17:27:43 -04:00
parent f2d9049a2e
commit 542b995b3b
2 changed files with 110 additions and 6 deletions

View file

@ -15,9 +15,9 @@ import mekanism.api.EnumColor;
import mekanism.api.IConfigurable; import mekanism.api.IConfigurable;
import mekanism.api.MekanismConfig.usage; import mekanism.api.MekanismConfig.usage;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.base.ITankManager;
import mekanism.common.base.IRedstoneControl; import mekanism.common.base.IRedstoneControl;
import mekanism.common.base.ISustainedTank; import mekanism.common.base.ISustainedTank;
import mekanism.common.base.ITankManager;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
@ -39,8 +39,15 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable, IRedstoneControl, IUpgradeTile, ITankManager @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable, IRedstoneControl, IUpgradeTile, ITankManager, IPeripheral
{ {
/** This pump's tank */ /** This pump's tank */
public FluidTank fluidTank = new FluidTank(10000); public FluidTank fluidTank = new FluidTank(10000);
@ -260,6 +267,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
else { else {
fluidTank.setFluid(null); fluidTank.setFluid(null);
} }
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
@ -279,6 +287,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
else { else {
data.add(0); data.add(0);
} }
data.add(controlType.ordinal()); data.add(controlType.ordinal());
return data; return data;
@ -519,4 +528,47 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
{ {
return new Object[] {fluidTank}; return new Object[] {fluidTank};
} }
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return new String[] {"reset"};
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{
case 0:
recurringNodes.clear();
return new Object[] {"Pump calculation reset."};
default:
return new Object[] {"Unknown command."};
}
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
} }

View file

@ -1,5 +1,7 @@
package mekanism.common.tile; package mekanism.common.tile;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashSet; import java.util.HashSet;
@ -15,7 +17,6 @@ import mekanism.common.util.ChargeUtils;
import mekanism.common.util.FluidContainerUtils; import mekanism.common.util.FluidContainerUtils;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.PipeUtils; import mekanism.common.util.PipeUtils;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -30,10 +31,15 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import cpw.mods.fml.common.Optional.Interface;
import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.lua.LuaException;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import io.netty.buffer.ByteBuf; @Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IPeripheral, IConfigurable, IFluidHandler, ISustainedTank
public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IConfigurable, IFluidHandler, ISustainedTank
{ {
public Set<Coord4D> activeNodes = new HashSet<Coord4D>(); public Set<Coord4D> activeNodes = new HashSet<Coord4D>();
public Set<Coord4D> usedNodes = new HashSet<Coord4D>(); public Set<Coord4D> usedNodes = new HashSet<Coord4D>();
@ -508,4 +514,50 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
{ {
return false; return false;
} }
@Override
@Method(modid = "ComputerCraft")
public String getType()
{
return getInventoryName();
}
@Override
@Method(modid = "ComputerCraft")
public String[] getMethodNames()
{
return new String[] {"reset"};
}
@Override
@Method(modid = "ComputerCraft")
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException
{
switch(method)
{
case 0:
activeNodes.clear();
usedNodes.clear();
finishedCalc = false;
return new Object[] {"Plenisher calculation reset."};
default:
return new Object[] {"Unknown command."};
}
}
@Override
@Method(modid = "ComputerCraft")
public void attach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public void detach(IComputerAccess computer) {}
@Override
@Method(modid = "ComputerCraft")
public boolean equals(IPeripheral other)
{
return this == other;
}
} }