A few ejector fixes
This commit is contained in:
parent
a22b33a629
commit
06dc2227f2
5 changed files with 51 additions and 43 deletions
|
@ -2,13 +2,13 @@ package mekanism.api.gas;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import mekanism.api.Coord4D;
|
import mekanism.api.Coord4D;
|
||||||
import mekanism.api.transmitters.ITransmitterTile;
|
import mekanism.api.transmitters.ITransmitterTile;
|
||||||
import mekanism.api.transmitters.TransmissionType;
|
import mekanism.api.transmitters.TransmissionType;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
@ -20,16 +20,11 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||||
*/
|
*/
|
||||||
public final class GasTransmission
|
public final class GasTransmission
|
||||||
{
|
{
|
||||||
/**
|
public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity, Collection<ForgeDirection> sides)
|
||||||
* Gets all the acceptors around a tile entity.
|
|
||||||
* @param tileEntity - center tile entity
|
|
||||||
* @return array of IGasAcceptors
|
|
||||||
*/
|
|
||||||
public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity)
|
|
||||||
{
|
{
|
||||||
IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null};
|
IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null};
|
||||||
|
|
||||||
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
|
for(ForgeDirection orientation : sides)
|
||||||
{
|
{
|
||||||
TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());
|
TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());
|
||||||
|
|
||||||
|
@ -41,6 +36,16 @@ public final class GasTransmission
|
||||||
|
|
||||||
return acceptors;
|
return acceptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the acceptors around a tile entity.
|
||||||
|
* @param tileEntity - center tile entity
|
||||||
|
* @return array of IGasAcceptors
|
||||||
|
*/
|
||||||
|
public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity)
|
||||||
|
{
|
||||||
|
return getConnectedAcceptors(tileEntity, Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the tube connections around a tile entity.
|
* Gets all the tube connections around a tile entity.
|
||||||
|
@ -125,12 +130,12 @@ public final class GasTransmission
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emits gas from a central block by splitting the received stack among the sides given.
|
* Emits gas from a central block by splitting the received stack among the sides given.
|
||||||
* @param sides - the list of sides to output from
|
|
||||||
* @param stack - the stack to output
|
* @param stack - the stack to output
|
||||||
* @param from - the TileEntity to output from
|
* @param from - the TileEntity to output from
|
||||||
|
* @param sides - the list of sides to output from
|
||||||
* @return the amount of gas emitted
|
* @return the amount of gas emitted
|
||||||
*/
|
*/
|
||||||
public static int emit(List<ForgeDirection> sides, GasStack stack, TileEntity from)
|
public static int emit(GasStack stack, TileEntity from, Collection<ForgeDirection> sides)
|
||||||
{
|
{
|
||||||
if(stack == null)
|
if(stack == null)
|
||||||
{
|
{
|
||||||
|
@ -138,7 +143,7 @@ public final class GasTransmission
|
||||||
}
|
}
|
||||||
|
|
||||||
List<IGasHandler> availableAcceptors = new ArrayList<IGasHandler>();
|
List<IGasHandler> availableAcceptors = new ArrayList<IGasHandler>();
|
||||||
IGasHandler[] possibleAcceptors = getConnectedAcceptors(from);
|
IGasHandler[] possibleAcceptors = getConnectedAcceptors(from, sides);
|
||||||
|
|
||||||
for(int i = 0; i < possibleAcceptors.length; i++)
|
for(int i = 0; i < possibleAcceptors.length; i++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||||
ChargeUtils.charge(0, this);
|
ChargeUtils.charge(0, this);
|
||||||
ChargeUtils.discharge(1, this);
|
ChargeUtils.discharge(1, this);
|
||||||
|
|
||||||
if(MekanismUtils.canFunction(this))
|
if(MekanismUtils.canFunction(this) && configComponent.isEjecting(TransmissionType.ENERGY))
|
||||||
{
|
{
|
||||||
CableUtils.emit(this);
|
CableUtils.emit(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,41 +84,45 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
{
|
{
|
||||||
if(inventory[0] != null && gasTank.getGas() != null)
|
|
||||||
{
|
|
||||||
gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
|
||||||
{
|
|
||||||
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this) && dumping != GasMode.DUMPING)
|
|
||||||
{
|
|
||||||
GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output));
|
|
||||||
gasTank.draw(GasTransmission.emit(new ArrayList(configComponent.getSidesForData(TransmissionType.GAS, facing, 2).clone()), toSend, this), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!worldObj.isRemote && dumping == GasMode.DUMPING)
|
|
||||||
{
|
|
||||||
gasTank.draw(8, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!worldObj.isRemote && dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < output)
|
|
||||||
{
|
|
||||||
gasTank.draw(output-gasTank.getNeeded(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!worldObj.isRemote)
|
if(!worldObj.isRemote)
|
||||||
{
|
{
|
||||||
|
if(inventory[0] != null && gasTank.getGas() != null)
|
||||||
|
{
|
||||||
|
gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
||||||
|
{
|
||||||
|
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(gasTank.getGas() != null && MekanismUtils.canFunction(this) && dumping != GasMode.DUMPING)
|
||||||
|
{
|
||||||
|
if(configComponent.isEjecting(TransmissionType.GAS))
|
||||||
|
{
|
||||||
|
GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output));
|
||||||
|
gasTank.draw(GasTransmission.emit(toSend, this, configComponent.getSidesForData(TransmissionType.GAS, facing, 2)), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dumping == GasMode.DUMPING)
|
||||||
|
{
|
||||||
|
gasTank.draw(8, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < output)
|
||||||
|
{
|
||||||
|
gasTank.draw(output-gasTank.getNeeded(), true);
|
||||||
|
}
|
||||||
|
|
||||||
int newGasAmount = gasTank.getStored();
|
int newGasAmount = gasTank.getStored();
|
||||||
|
|
||||||
if(newGasAmount != currentGasAmount)
|
if(newGasAmount != currentGasAmount)
|
||||||
{
|
{
|
||||||
markDirty();
|
MekanismUtils.saveChunk(this);
|
||||||
currentGasAmount = newGasAmount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentGasAmount = newGasAmount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
||||||
|
|
||||||
if(fluidTank.getFluidAmount() != prevAmount)
|
if(fluidTank.getFluidAmount() != prevAmount)
|
||||||
{
|
{
|
||||||
|
MekanismUtils.saveChunk(this);
|
||||||
needsPacket = true;
|
needsPacket = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import mekanism.api.gas.GasTransmission;
|
||||||
import mekanism.api.transmitters.TransmissionType;
|
import mekanism.api.transmitters.TransmissionType;
|
||||||
import mekanism.common.SideData;
|
import mekanism.common.SideData;
|
||||||
import mekanism.common.base.IEjector;
|
import mekanism.common.base.IEjector;
|
||||||
import mekanism.common.base.ILogisticalTransporter;
|
|
||||||
import mekanism.common.base.ISideConfiguration;
|
import mekanism.common.base.ISideConfiguration;
|
||||||
import mekanism.common.base.ITankManager;
|
import mekanism.common.base.ITankManager;
|
||||||
import mekanism.common.base.ITileComponent;
|
import mekanism.common.base.ITileComponent;
|
||||||
|
@ -121,7 +120,7 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
||||||
if(tank.getStored() > 0)
|
if(tank.getStored() > 0)
|
||||||
{
|
{
|
||||||
GasStack toEmit = tank.getGas().copy().withAmount(Math.min(GAS_OUTPUT, tank.getStored()));
|
GasStack toEmit = tank.getGas().copy().withAmount(Math.min(GAS_OUTPUT, tank.getStored()));
|
||||||
int emit = GasTransmission.emit(outputSides, toEmit, tileEntity);
|
int emit = GasTransmission.emit(toEmit, tileEntity, outputSides);
|
||||||
tank.draw(emit, true);
|
tank.draw(emit, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +145,6 @@ public class TileComponentEjector implements ITileComponent, IEjector
|
||||||
public List<ForgeDirection> getOutputSides(TransmissionType type, SideData data)
|
public List<ForgeDirection> getOutputSides(TransmissionType type, SideData data)
|
||||||
{
|
{
|
||||||
List<ForgeDirection> outputSides = new ArrayList<ForgeDirection>();
|
List<ForgeDirection> outputSides = new ArrayList<ForgeDirection>();
|
||||||
|
|
||||||
ISideConfiguration configurable = (ISideConfiguration)tileEntity;
|
ISideConfiguration configurable = (ISideConfiguration)tileEntity;
|
||||||
|
|
||||||
for(int i = 0; i < configurable.getConfig().getConfig(type).length; i++)
|
for(int i = 0; i < configurable.getConfig().getConfig(type).length; i++)
|
||||||
|
|
Loading…
Reference in a new issue