Many fixes!
This commit is contained in:
parent
ff54b5445d
commit
96ba50a673
26 changed files with 396 additions and 862 deletions
|
@ -14,7 +14,7 @@ public interface IStrictEnergyAcceptor extends IStrictEnergyStorage
|
|||
* @param amount - amount to transfer
|
||||
* @return rejects
|
||||
*/
|
||||
public double transferEnergyToAcceptor(double amount);
|
||||
public double transferEnergyToAcceptor(ForgeDirection side, double amount);
|
||||
|
||||
/**
|
||||
* Whether or not this tile entity accepts energy from a certain side.
|
||||
|
|
|
@ -81,13 +81,15 @@ public class Gas
|
|||
return fluid != null;
|
||||
}
|
||||
|
||||
public void registerFluid()
|
||||
public Gas registerFluid()
|
||||
{
|
||||
if(fluid == null)
|
||||
{
|
||||
fluid = new Fluid(getName()).setGaseous(true);
|
||||
FluidRegistry.registerFluid(fluid);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -240,13 +240,13 @@ public class GuiConfiguration extends GuiMekanism
|
|||
{
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
TileEntity tile = (TileEntity)configurable;
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
TileEntity tile = (TileEntity)configurable;
|
||||
|
||||
{
|
||||
if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20)
|
||||
{
|
||||
int guiId = MachineType.get(tile.getBlockType().blockID, tile.getBlockMetadata()).guiId;
|
||||
|
@ -265,37 +265,37 @@ public class GuiConfiguration extends GuiMekanism
|
|||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.STRICT_INPUT, Object3D.get(tile)));
|
||||
}
|
||||
|
||||
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65)
|
||||
{
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.EJECT_COLOR, Object3D.get(tile)));
|
||||
}
|
||||
|
||||
for(int i = 0; i < slotPosMap.size(); i++)
|
||||
{
|
||||
int x = slotPosMap.get(i).xPos;
|
||||
int y = slotPosMap.get(i).yPos;
|
||||
|
||||
if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.SIDE_DATA, Object3D.get(tile), i));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < inputPosMap.size(); i++)
|
||||
{
|
||||
int x = inputPosMap.get(i).xPos;
|
||||
int y = inputPosMap.get(i).yPos;
|
||||
|
||||
if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.INPUT_COLOR, Object3D.get(tile), i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 49 && yAxis <= 65)
|
||||
{
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.EJECT_COLOR, Object3D.get(tile), button));
|
||||
}
|
||||
|
||||
for(int i = 0; i < slotPosMap.size(); i++)
|
||||
{
|
||||
int x = slotPosMap.get(i).xPos;
|
||||
int y = slotPosMap.get(i).yPos;
|
||||
|
||||
if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.SIDE_DATA, Object3D.get(tile), button, i));
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < inputPosMap.size(); i++)
|
||||
{
|
||||
int x = inputPosMap.get(i).xPos;
|
||||
int y = inputPosMap.get(i).yPos;
|
||||
|
||||
if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketConfigurationUpdate().setParams(ConfigurationPacket.INPUT_COLOR, Object3D.get(tile), button, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class GuiPos
|
||||
|
|
|
@ -137,11 +137,11 @@ public class GuiLogisticalSorter extends GuiMekanism
|
|||
{
|
||||
super.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15)
|
||||
{
|
||||
dragOffset = yAxis - (getScroll()+18);
|
||||
|
@ -172,15 +172,6 @@ public class GuiLogisticalSorter extends GuiMekanism
|
|||
}
|
||||
}
|
||||
|
||||
if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153)
|
||||
{
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(0);
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124)
|
||||
{
|
||||
ArrayList data = new ArrayList();
|
||||
|
@ -199,6 +190,16 @@ public class GuiLogisticalSorter extends GuiMekanism
|
|||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153)
|
||||
{
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(0);
|
||||
data.add(button);
|
||||
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -285,11 +285,11 @@ public class GuiTItemStackFilter extends GuiMekanism
|
|||
minField.mouseClicked(mouseX, mouseY, button);
|
||||
maxField.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
|
@ -313,17 +313,29 @@ public class GuiTItemStackFilter extends GuiMekanism
|
|||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
||||
{
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
filter.color = TransporterUtils.increment(filter.color);
|
||||
}
|
||||
|
||||
if(xAxis >= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
filter.sizeMode = !filter.sizeMode;
|
||||
}
|
||||
}
|
||||
|
||||
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
||||
{
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
filter.color = TransporterUtils.increment(filter.color);
|
||||
}
|
||||
else if(button == 1)
|
||||
{
|
||||
filter.color = TransporterUtils.decrement(filter.color);
|
||||
}
|
||||
else if(button == 2)
|
||||
{
|
||||
filter.color = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,29 +279,41 @@ public class GuiTOreDictFilter extends GuiMekanism
|
|||
|
||||
oreDictText.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
int xAxis = (mouseX - (width - xSize) / 2);
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
|
||||
{
|
||||
if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
PacketHandler.sendPacket(Transmission.SERVER, new PacketLogisticalSorterGui().setParams(SorterGuiPacket.SERVER, Object3D.get(tileEntity), 0));
|
||||
}
|
||||
|
||||
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
||||
{
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
filter.color = TransporterUtils.increment(filter.color);
|
||||
}
|
||||
|
||||
if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59)
|
||||
{
|
||||
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
||||
setOreDictKey();
|
||||
}
|
||||
}
|
||||
|
||||
if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60)
|
||||
{
|
||||
mc.sndManager.playSoundFX("mekanism:etc.Ding", 1.0F, 1.0F);
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
filter.color = TransporterUtils.increment(filter.color);
|
||||
}
|
||||
else if(button == 1)
|
||||
{
|
||||
filter.color = TransporterUtils.decrement(filter.color);
|
||||
}
|
||||
else if(button == 2)
|
||||
{
|
||||
filter.color = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStackList(String oreName)
|
||||
|
|
|
@ -19,7 +19,6 @@ import mekanism.api.transmitters.TransmissionType;
|
|||
import mekanism.common.tileentity.TileEntityUniversalCable;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -171,7 +170,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
if(acceptor instanceof IStrictEnergyAcceptor)
|
||||
{
|
||||
energyToSend -= (currentSending - ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(currentSending));
|
||||
energyToSend -= (currentSending - ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending));
|
||||
}
|
||||
else if(acceptor instanceof IEnergyHandler)
|
||||
{
|
||||
|
@ -224,11 +223,13 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
|
||||
for(TileEntity acceptor : copy)
|
||||
{
|
||||
ForgeDirection side = acceptorDirections.get(acceptor);
|
||||
|
||||
if(acceptor instanceof IStrictEnergyAcceptor)
|
||||
{
|
||||
IStrictEnergyAcceptor handler = (IStrictEnergyAcceptor)acceptor;
|
||||
|
||||
if(handler.canReceiveEnergy(acceptorDirections.get(acceptor).getOpposite()))
|
||||
if(handler.canReceiveEnergy(side.getOpposite()))
|
||||
{
|
||||
if(handler.getMaxEnergy() - handler.getEnergy() > 0)
|
||||
{
|
||||
|
@ -240,9 +241,13 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
IEnergyHandler handler = (IEnergyHandler)acceptor;
|
||||
|
||||
if(handler.canInterface(acceptorDirections.get(acceptor).getOpposite()))
|
||||
if(handler.canInterface(side.getOpposite()))
|
||||
{
|
||||
if(handler.receiveEnergy(acceptorDirections.get(acceptor).getOpposite(), 1, true) > 0)
|
||||
if(handler.receiveEnergy(side.getOpposite(), 1, true) > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
}
|
||||
else if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
}
|
||||
|
@ -252,7 +257,7 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
IEnergySink handler = (IEnergySink)acceptor;
|
||||
|
||||
if(handler.acceptsEnergyFrom(null, acceptorDirections.get(acceptor).getOpposite()))
|
||||
if(handler.acceptsEnergyFrom(null, side.getOpposite()))
|
||||
{
|
||||
if(Math.min((handler.demandedEnergyUnits()*Mekanism.FROM_IC2), (handler.getMaxSafeInput()*Mekanism.FROM_IC2)) > 0)
|
||||
{
|
||||
|
@ -264,9 +269,9 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
IElectrical handler = (IElectrical)acceptor;
|
||||
|
||||
if(handler.canConnect(acceptorDirections.get(acceptor).getOpposite()))
|
||||
if(handler.canConnect(side.getOpposite()))
|
||||
{
|
||||
if(handler.getRequest(acceptorDirections.get(acceptor).getOpposite()) > 0)
|
||||
if(handler.getRequest(side.getOpposite()) > 0)
|
||||
{
|
||||
toReturn.add(acceptor);
|
||||
}
|
||||
|
@ -276,11 +281,11 @@ public class EnergyNetwork extends DynamicNetwork<TileEntity, EnergyNetwork>
|
|||
{
|
||||
IPowerReceptor handler = (IPowerReceptor)acceptor;
|
||||
|
||||
if(handler.getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()) != null)
|
||||
if(handler.getPowerReceiver(side.getOpposite()) != null)
|
||||
{
|
||||
if((handler.getPowerReceiver(acceptorDirections.get(acceptor).getOpposite()).powerRequest()*Mekanism.FROM_BC) > 0)
|
||||
if((handler.getPowerReceiver(side.getOpposite()).powerRequest()*Mekanism.FROM_BC) > 0)
|
||||
{
|
||||
TileEntityUniversalCable cable = (TileEntityUniversalCable)Object3D.get(acceptor).getFromSide(acceptorDirections.get(acceptor).getOpposite()).getTileEntity(acceptor.worldObj);
|
||||
TileEntityUniversalCable cable = (TileEntityUniversalCable)Object3D.get(acceptor).getFromSide(side.getOpposite()).getTileEntity(acceptor.worldObj);
|
||||
|
||||
if(cable != null && !cable.getBuildCraftIgnored().contains(acceptor))
|
||||
{
|
||||
|
|
|
@ -26,6 +26,8 @@ public class PacketConfigurationUpdate implements IMekanismPacket
|
|||
|
||||
public int inputSide;
|
||||
|
||||
public int clickType;
|
||||
|
||||
public ConfigurationPacket packetType;
|
||||
|
||||
@Override
|
||||
|
@ -41,14 +43,21 @@ public class PacketConfigurationUpdate implements IMekanismPacket
|
|||
|
||||
object3D = (Object3D)data[1];
|
||||
|
||||
if(packetType == ConfigurationPacket.EJECT_COLOR)
|
||||
{
|
||||
clickType = (Integer)data[2];
|
||||
}
|
||||
|
||||
if(packetType == ConfigurationPacket.SIDE_DATA)
|
||||
{
|
||||
configIndex = (Integer)data[2];
|
||||
clickType = (Integer)data[2];
|
||||
configIndex = (Integer)data[3];
|
||||
}
|
||||
|
||||
if(packetType == ConfigurationPacket.INPUT_COLOR)
|
||||
{
|
||||
inputSide = (Integer)data[2];
|
||||
clickType = (Integer)data[2];
|
||||
inputSide = (Integer)data[3];
|
||||
}
|
||||
|
||||
return this;
|
||||
|
@ -73,20 +82,60 @@ public class PacketConfigurationUpdate implements IMekanismPacket
|
|||
}
|
||||
else if(packetType == ConfigurationPacket.SIDE_DATA)
|
||||
{
|
||||
clickType = dataStream.readInt();
|
||||
configIndex = dataStream.readInt();
|
||||
|
||||
MekanismUtils.incrementOutput((IConfigurable)tile, configIndex);
|
||||
if(clickType == 0)
|
||||
{
|
||||
MekanismUtils.incrementOutput((IConfigurable)tile, configIndex);
|
||||
}
|
||||
else if(clickType == 1)
|
||||
{
|
||||
MekanismUtils.decrementOutput((IConfigurable)tile, configIndex);
|
||||
}
|
||||
else if(clickType == 2)
|
||||
{
|
||||
((IConfigurable)tile).getConfiguration()[configIndex] = 0;
|
||||
}
|
||||
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(object3D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), object3D, 50D);
|
||||
}
|
||||
else if(packetType == ConfigurationPacket.EJECT_COLOR)
|
||||
{
|
||||
config.getEjector().setOutputColor(TransporterUtils.increment(config.getEjector().getOutputColor()));
|
||||
clickType = dataStream.readInt();
|
||||
|
||||
if(clickType == 0)
|
||||
{
|
||||
config.getEjector().setOutputColor(TransporterUtils.increment(config.getEjector().getOutputColor()));
|
||||
}
|
||||
else if(clickType == 1)
|
||||
{
|
||||
config.getEjector().setOutputColor(TransporterUtils.decrement(config.getEjector().getOutputColor()));
|
||||
}
|
||||
else if(clickType == 2)
|
||||
{
|
||||
config.getEjector().setOutputColor(null);
|
||||
}
|
||||
}
|
||||
else if(packetType == ConfigurationPacket.INPUT_COLOR)
|
||||
{
|
||||
clickType = dataStream.readInt();
|
||||
inputSide = dataStream.readInt();
|
||||
|
||||
ForgeDirection side = ForgeDirection.getOrientation(inputSide);
|
||||
config.getEjector().setInputColor(side, TransporterUtils.increment(config.getEjector().getInputColor(side)));
|
||||
|
||||
if(clickType == 0)
|
||||
{
|
||||
config.getEjector().setInputColor(side, TransporterUtils.increment(config.getEjector().getInputColor(side)));
|
||||
}
|
||||
else if(clickType == 1)
|
||||
{
|
||||
config.getEjector().setInputColor(side, TransporterUtils.decrement(config.getEjector().getInputColor(side)));
|
||||
}
|
||||
else if(clickType == 2)
|
||||
{
|
||||
config.getEjector().setInputColor(side, null);
|
||||
}
|
||||
}
|
||||
else if(packetType == ConfigurationPacket.STRICT_INPUT)
|
||||
{
|
||||
|
|
|
@ -415,14 +415,14 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
|||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
public double transferEnergyToAcceptor(ForgeDirection side, double amount)
|
||||
{
|
||||
if(getInv() == null)
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
return getInv().transferEnergyToAcceptor(amount);
|
||||
return getInv().transferEnergyToAcceptor(side, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.IEjector;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.SideData;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.client.sound.IHasSound;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IElectricMachine;
|
||||
|
@ -22,16 +19,14 @@ import mekanism.common.TileComponentUpgrade;
|
|||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import dan200.computer.api.IComputerAccess;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IStrictEnergyAcceptor, IRedstoneControl
|
||||
public abstract class TileEntityBasicMachine extends TileEntityElectricBlock implements IElectricMachine, IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IRedstoneControl
|
||||
{
|
||||
/** This machine's side configuration. */
|
||||
public byte[] sideConfig;
|
||||
|
@ -206,43 +201,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
Mekanism.proxy.unregisterSound(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy()-getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy <= neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scaled progress level for the GUI.
|
||||
|
@ -279,30 +237,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
clientActive = active;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
|
@ -334,12 +268,6 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
|
|||
return sideOutputs.get(sideConfig[MekanismUtils.getBaseOrientation(side, facing)]).availableSlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<SideData> getSideData()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.item.ElectricItem;
|
||||
import ic2.api.item.IElectricItem;
|
||||
|
||||
|
@ -12,7 +11,6 @@ import java.util.Random;
|
|||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.EnergizedItemManager;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.client.sound.IHasSound;
|
||||
import mekanism.common.EntityRobit;
|
||||
import mekanism.common.IActiveState;
|
||||
|
@ -36,7 +34,7 @@ import cofh.api.energy.IEnergyContainerItem;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityChargepad extends TileEntityElectricBlock implements IActiveState, IEnergySink, IStrictEnergyAcceptor, IHasSound
|
||||
public class TileEntityChargepad extends TileEntityElectricBlock implements IActiveState, IHasSound
|
||||
{
|
||||
public boolean isActive;
|
||||
|
||||
|
@ -227,68 +225,6 @@ public class TileEntityChargepad extends TileEntityElectricBlock implements IAct
|
|||
{
|
||||
return side != 0 && side != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return getConsumingSides().contains(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy()-getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy <= neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return getConsumingSides().contains(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSoundPath()
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -9,7 +7,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.common.HashList;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IAdvancedBoundingBlock;
|
||||
|
@ -52,7 +49,7 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IPeripheral, IEnergySink, IStrictEnergyAcceptor, IUpgradeTile, IRedstoneControl, IActiveState, IAdvancedBoundingBlock
|
||||
public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IPeripheral, IUpgradeTile, IRedstoneControl, IActiveState, IAdvancedBoundingBlock
|
||||
{
|
||||
public List<Object3D> oresToMine = new ArrayList<Object3D>();
|
||||
|
||||
|
@ -791,66 +788,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double amount)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
double givenEnergy = amount*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy < neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededGas = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededGas)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededGas;
|
||||
rejects = amount-neededGas;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy()
|
||||
|
@ -858,12 +795,6 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
|||
return MekanismUtils.getEnergy(getEnergyMultiplier(), MAX_ELECTRICITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneControl getControlType()
|
||||
{
|
||||
|
|
|
@ -2,18 +2,24 @@ package mekanism.common.tileentity;
|
|||
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.api.tile.IEnergyStorage;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.ICableOutputter;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.ITileNetwork;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -28,7 +34,7 @@ import cofh.api.energy.IEnergyHandler;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements IWrenchable, ITileNetwork, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler
|
||||
public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements IWrenchable, ITileNetwork, IPowerReceptor, IEnergyTile, IElectrical, IElectricalStorage, IConnector, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter
|
||||
{
|
||||
/** How much energy is stored in this block. */
|
||||
public double electricityStored;
|
||||
|
@ -325,12 +331,156 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
@Override
|
||||
public int getEnergyStored(ForgeDirection from)
|
||||
{
|
||||
return (int)(getEnergy()*Mekanism.TO_TE);
|
||||
return (int)Math.round(getEnergy()*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from)
|
||||
{
|
||||
return (int)(getMaxEnergy()*Mekanism.TO_TE);
|
||||
return (int)Math.round(getMaxEnergy()*Mekanism.TO_TE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStored(int energy)
|
||||
{
|
||||
setEnergy(energy*Mekanism.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addEnergy(int amount)
|
||||
{
|
||||
setEnergy(getEnergy() + amount*Mekanism.FROM_IC2);
|
||||
return (int)Math.round(getEnergy()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleporterCompatible(ForgeDirection side)
|
||||
{
|
||||
return side == getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOutputTo(ForgeDirection side)
|
||||
{
|
||||
return side == getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return direction != getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored()
|
||||
{
|
||||
return (int)Math.round(getEnergy()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOutput()
|
||||
{
|
||||
return (int)Math.round(getMaxOutput()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
return Math.min(getEnergy()*Mekanism.TO_IC2, getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return side != getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction)
|
||||
{
|
||||
return direction == getOutputtingSide() && !(receiver instanceof TileEntityUniversalCable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOutputEnergyUnitsPerTick()
|
||||
{
|
||||
return getMaxOutput()*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount)
|
||||
{
|
||||
setEnergy(getEnergy()-amount*Mekanism.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
if(!getConsumingSides().contains(direction))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy <= neededEnergy)
|
||||
{
|
||||
setEnergy(getEnergy() + givenEnergy);
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
setEnergy(getEnergy() + neededEnergy);
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(ForgeDirection side, double amount)
|
||||
{
|
||||
if(!getConsumingSides().contains(side))
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
setEnergy(getEnergy() + amount);
|
||||
}
|
||||
else {
|
||||
setEnergy(getEnergy() + neededElectricity);
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -15,7 +12,7 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityElectricChest extends TileEntityElectricBlock implements IEnergySink, IStrictEnergyAcceptor
|
||||
public class TileEntityElectricChest extends TileEntityElectricBlock
|
||||
{
|
||||
public String password = "";
|
||||
|
||||
|
@ -177,66 +174,4 @@ public class TileEntityElectricChest extends TileEntityElectricBlock implements
|
|||
{
|
||||
return side != 0 && side != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy < neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -11,7 +9,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
|
@ -33,7 +30,7 @@ import net.minecraftforge.fluids.IFluidHandler;
|
|||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IEnergySink, IStrictEnergyAcceptor
|
||||
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank
|
||||
{
|
||||
/** This pump's tank */
|
||||
public FluidTank fluidTank;
|
||||
|
@ -424,68 +421,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
|||
return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return getConsumingSides().contains(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy <= neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return getConsumingSides().contains(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetFacing(int side)
|
||||
{
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
import ic2.api.energy.tile.IEnergySource;
|
||||
import ic2.api.tile.IEnergyStorage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.ICableOutputter;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.Tier.EnergyCubeTier;
|
||||
import mekanism.common.network.PacketTileEntity;
|
||||
import mekanism.common.util.CableUtils;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
|
@ -30,7 +27,7 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEnergySink, IEnergySource, IEnergyStorage, IPowerReceptor, IPeripheral, ICableOutputter, IStrictEnergyAcceptor, IRedstoneControl
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IPowerReceptor, IPeripheral, IRedstoneControl
|
||||
{
|
||||
/** This Energy Cube's tier. */
|
||||
public EnergyCubeTier tier = EnergyCubeTier.BASIC;
|
||||
|
@ -41,6 +38,8 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType;
|
||||
|
||||
public int prevScale;
|
||||
|
||||
/**
|
||||
* A block used to store and transfer electricity.
|
||||
* @param energy - maximum energy this block can hold.
|
||||
|
@ -110,115 +109,12 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
{
|
||||
return ForgeDirection.getOrientation(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return direction != getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStored()
|
||||
{
|
||||
return (int)(getEnergy()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity()
|
||||
{
|
||||
return (int)(getMaxEnergy()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOutput()
|
||||
{
|
||||
return (int)(tier.OUTPUT*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOfferedEnergy()
|
||||
{
|
||||
return Math.min(getEnergy()*Mekanism.TO_IC2, getOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEnergy(double amount)
|
||||
{
|
||||
setEnergy(getEnergy()-amount*Mekanism.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy <= neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSetFacing(int side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return side != getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction)
|
||||
{
|
||||
return direction == getOutputtingSide() && !(receiver instanceof TileEntityUniversalCable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getOutputEnergyUnitsPerTick()
|
||||
{
|
||||
return tier.OUTPUT*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxEnergy()
|
||||
|
@ -338,37 +234,6 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStored(int energy)
|
||||
{
|
||||
setEnergy(energy*Mekanism.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addEnergy(int amount)
|
||||
{
|
||||
setEnergy(getEnergy() + amount*Mekanism.FROM_IC2);
|
||||
return (int)(getEnergy()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleporterCompatible(ForgeDirection side)
|
||||
{
|
||||
return side == getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canOutputTo(ForgeDirection side)
|
||||
{
|
||||
return side == getOutputtingSide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy)
|
||||
{
|
||||
|
@ -381,6 +246,18 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
|
|||
onInventoryChanged();
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
int newScale = getScaledEnergyLevel(100);
|
||||
|
||||
if(newScale != prevScale)
|
||||
{
|
||||
PacketHandler.sendPacket(Transmission.CLIENTS_RANGE, new PacketTileEntity().setParams(Object3D.get(this), getNetworkedData(new ArrayList())), Object3D.get(this), 50D);
|
||||
}
|
||||
|
||||
prevScale = newScale;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRedstoneLevel()
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
|
@ -9,7 +7,6 @@ import mekanism.api.IConfigurable;
|
|||
import mekanism.api.IEjector;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.SideData;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
|
@ -43,7 +40,7 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityFactory extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IStrictEnergyAcceptor, IRedstoneControl, IGasAcceptor, IGasStorage, ITubeConnection
|
||||
public class TileEntityFactory extends TileEntityElectricBlock implements IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IRedstoneControl, IGasAcceptor, IGasStorage, ITubeConnection
|
||||
{
|
||||
/** This Factory's tier. */
|
||||
public FactoryTier tier;
|
||||
|
@ -262,7 +259,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
if(recipeType == RecipeType.PURIFYING.ordinal())
|
||||
{
|
||||
GasStack removed = GasUtils.removeGas(inventory[4], GasRegistry.getGas("oxygen"), getMaxSecondaryEnergy()-secondaryEnergyStored);
|
||||
setSecondaryEnergy(secondaryEnergyStored - (removed != null ? removed.amount : 0));
|
||||
setSecondaryEnergy(secondaryEnergyStored + (removed != null ? removed.amount : 0));
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -550,12 +547,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getInputSlot(int operation)
|
||||
{
|
||||
|
@ -566,30 +557,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
return tier.processes+5+operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
|
@ -673,12 +640,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
return MekanismUtils.getEnergy(getEnergyMultiplier(), MAX_ELECTRICITY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy()-getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
|
@ -699,37 +660,6 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy <= neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
|
|
|
@ -234,7 +234,20 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
|||
|
||||
if(type == 0)
|
||||
{
|
||||
color = TransporterUtils.increment(color);
|
||||
int clickType = dataStream.readInt();
|
||||
|
||||
if(clickType == 0)
|
||||
{
|
||||
color = TransporterUtils.increment(color);
|
||||
}
|
||||
else if(clickType == 1)
|
||||
{
|
||||
color = TransporterUtils.decrement(color);
|
||||
}
|
||||
else if(clickType == 2)
|
||||
{
|
||||
color = null;
|
||||
}
|
||||
}
|
||||
else if(type == 1)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
|
@ -9,7 +7,6 @@ import mekanism.api.IConfigurable;
|
|||
import mekanism.api.IEjector;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.SideData;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.infuse.InfuseObject;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
|
@ -32,8 +29,6 @@ import mekanism.common.util.ChargeUtils;
|
|||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
|
@ -41,7 +36,7 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IStrictEnergyAcceptor, IRedstoneControl
|
||||
public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implements IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IRedstoneControl
|
||||
{
|
||||
/** This machine's side configuration. */
|
||||
public byte[] sideConfig = new byte[] {2, 1, 0, 5, 3, 4};
|
||||
|
@ -355,30 +350,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbtTags)
|
||||
|
@ -526,12 +497,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
{
|
||||
return side != 0 && side != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
|
@ -552,43 +517,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityElectricBlock implem
|
|||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double givenEnergy = i*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy < neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<SideData> getSideData()
|
||||
|
|
|
@ -102,7 +102,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
|||
if(inventory[1] != null && secondaryEnergyStored < MAX_SECONDARY_ENERGY)
|
||||
{
|
||||
GasStack removed = GasUtils.removeGas(inventory[1], GasRegistry.getGas("oxygen"), MAX_SECONDARY_ENERGY-secondaryEnergyStored);
|
||||
setSecondaryEnergy(secondaryEnergyStored - (removed != null ? removed.amount : 0));
|
||||
setSecondaryEnergy(secondaryEnergyStored + (removed != null ? removed.amount : 0));
|
||||
}
|
||||
|
||||
super.handleSecondaryFuel();
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
package mekanism.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.Teleporter;
|
||||
import mekanism.common.PacketHandler.Transmission;
|
||||
import mekanism.common.Teleporter;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketPortalFX;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
|
@ -30,7 +27,7 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityTeleporter extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IStrictEnergyAcceptor
|
||||
public class TileEntityTeleporter extends TileEntityElectricBlock implements IPeripheral
|
||||
{
|
||||
/** This teleporter's frequency. */
|
||||
public Teleporter.Code code;
|
||||
|
@ -351,42 +348,12 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IEn
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
|
||||
{
|
||||
return ChargeUtils.canBeOutputted(itemstack, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededGas = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededGas)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededGas;
|
||||
rejects = amount-neededGas;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType()
|
||||
|
@ -459,41 +426,4 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements IEn
|
|||
|
||||
@Override
|
||||
public void detach(IComputerAccess computer) {}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double amount)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return amount;
|
||||
}
|
||||
|
||||
double givenEnergy = amount*Mekanism.FROM_IC2;
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(givenEnergy < neededEnergy)
|
||||
{
|
||||
electricityStored += givenEnergy;
|
||||
}
|
||||
else if(givenEnergy > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = givenEnergy-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ public final class CableUtils
|
|||
{
|
||||
IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity;
|
||||
double toSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput());
|
||||
emitter.setEnergy(emitter.getEnergy() - (toSend - acceptor.transferEnergyToAcceptor(toSend)));
|
||||
emitter.setEnergy(emitter.getEnergy() - (toSend - acceptor.transferEnergyToAcceptor(emitter.getOutputtingSide().getOpposite(), toSend)));
|
||||
}
|
||||
else if(tileEntity instanceof IEnergyHandler)
|
||||
{
|
||||
|
|
|
@ -550,6 +550,21 @@ public final class MekanismUtils
|
|||
}
|
||||
}
|
||||
|
||||
public static void decrementOutput(IConfigurable config, int side)
|
||||
{
|
||||
int max = config.getSideData().size()-1;
|
||||
int current = config.getSideData().indexOf(config.getSideData().get(config.getConfiguration()[side]));
|
||||
|
||||
if(current > 0)
|
||||
{
|
||||
config.getConfiguration()[side] = (byte)(current-1);
|
||||
}
|
||||
else if(current == 0)
|
||||
{
|
||||
config.getConfiguration()[side] = (byte)max;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the operating ticks required for a machine via it's upgrades.
|
||||
* @param speedUpgrade - number of speed upgrades
|
||||
|
|
|
@ -197,6 +197,20 @@ public final class TransporterUtils
|
|||
return colors.get(colors.indexOf(color)+1);
|
||||
}
|
||||
|
||||
public static EnumColor decrement(EnumColor color)
|
||||
{
|
||||
if(color == null)
|
||||
{
|
||||
return colors.get(colors.size()-1);
|
||||
}
|
||||
else if(colors.indexOf(color) == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return colors.get(colors.indexOf(color)-1);
|
||||
}
|
||||
|
||||
public static boolean checkDiversionLogic(TileEntity currTile, TileEntity tile, int side)
|
||||
{
|
||||
if(currTile instanceof TileEntityDiversionTransporter)
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package mekanism.generators.common.tileentity;
|
||||
|
||||
import ic2.api.energy.tile.IEnergySink;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
|
@ -44,7 +41,7 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IEnergySink, IFluidHandler, IPeripheral, ITubeConnection, IStrictEnergyAcceptor, ISustainedTank
|
||||
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedTank
|
||||
{
|
||||
/** This separator's water slot. */
|
||||
public FluidTank waterTank = new FluidTank(24000);
|
||||
|
@ -268,30 +265,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
return new int[] {0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public double transferEnergyToAcceptor(double amount)
|
||||
{
|
||||
double rejects = 0;
|
||||
double neededElectricity = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(amount <= neededElectricity)
|
||||
{
|
||||
electricityStored += amount;
|
||||
}
|
||||
else {
|
||||
electricityStored += neededElectricity;
|
||||
rejects = amount-neededElectricity;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveEnergy(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scaled hydrogen level for the GUI.
|
||||
* @param i - multiplier
|
||||
|
@ -390,48 +363,6 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
|
|||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double demandedEnergyUnits()
|
||||
{
|
||||
return (MAX_ELECTRICITY - electricityStored)*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxSafeInput()
|
||||
{
|
||||
return 2048;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double injectEnergyUnits(ForgeDirection direction, double i)
|
||||
{
|
||||
if(Object3D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof TileEntityUniversalCable)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
double rejects = 0;
|
||||
double neededEnergy = getMaxEnergy()-getEnergy();
|
||||
|
||||
if(i <= neededEnergy)
|
||||
{
|
||||
electricityStored += i;
|
||||
}
|
||||
else if(i > neededEnergy)
|
||||
{
|
||||
electricityStored += neededEnergy;
|
||||
rejects = i-neededEnergy;
|
||||
}
|
||||
|
||||
return rejects*Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return direction != ForgeDirection.getOrientation(facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags)
|
||||
{
|
||||
|
|
|
@ -48,7 +48,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements
|
|||
if(inventory[0] != null && hydrogenStored < MAX_HYDROGEN)
|
||||
{
|
||||
GasStack removed = GasUtils.removeGas(inventory[0], GasRegistry.getGas("hydrogen"), getMaxGas()-hydrogenStored);
|
||||
setGas(new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored - (removed != null ? removed.amount : 0)));
|
||||
setGas(new GasStack(GasRegistry.getGas("hydrogen"), hydrogenStored + (removed != null ? removed.amount : 0)));
|
||||
}
|
||||
|
||||
if(canOperate())
|
||||
|
|
Loading…
Reference in a new issue