diff options
| author | Draknyte1 <Draknyte1@hotmail.com> | 2016-02-29 19:33:00 +1000 |
|---|---|---|
| committer | Draknyte1 <Draknyte1@hotmail.com> | 2016-02-29 19:33:00 +1000 |
| commit | 6245b6a3eaf1ce475f6624da97ab3f04dcfd35f8 (patch) | |
| tree | b8dab0dae8673f54ed5ff80a5bedfcfe4830cc6b /src/Java/miscutil/enderio/conduit/gas | |
| parent | bcccdaf05ee909ba98f096d9822113bed8f283cd (diff) | |
| download | GT5-Unofficial-6245b6a3eaf1ce475f6624da97ab3f04dcfd35f8.tar.gz GT5-Unofficial-6245b6a3eaf1ce475f6624da97ab3f04dcfd35f8.tar.bz2 GT5-Unofficial-6245b6a3eaf1ce475f6624da97ab3f04dcfd35f8.zip | |
V0.9.2 Release - Removed dev features and some messy code to push a 0.9.2 snapshop codebase.
Diffstat (limited to 'src/Java/miscutil/enderio/conduit/gas')
12 files changed, 0 insertions, 1622 deletions
diff --git a/src/Java/miscutil/enderio/conduit/gas/AbstractGasConduit.java b/src/Java/miscutil/enderio/conduit/gas/AbstractGasConduit.java deleted file mode 100644 index 0cdee252b0..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/AbstractGasConduit.java +++ /dev/null @@ -1,203 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.EnumMap; -import java.util.HashMap; -import java.util.Map; - -import mekanism.api.gas.IGasHandler; -import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.AbstractConduit; -import crazypants.enderio.conduit.ConduitUtil; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.IConduitBundle; -import crazypants.enderio.machine.RedstoneControlMode; -import crazypants.enderio.machine.reservoir.TileReservoir; -import crazypants.util.BlockCoord; -import crazypants.util.DyeColor; - -public abstract class AbstractGasConduit - extends AbstractConduit - implements IGasConduit -{ - protected final EnumMap<ForgeDirection, RedstoneControlMode> extractionModes = new EnumMap(ForgeDirection.class); - protected final EnumMap<ForgeDirection, DyeColor> extractionColors = new EnumMap(ForgeDirection.class); - protected final Map<ForgeDirection, Integer> externalRedstoneSignals = new HashMap(); - protected boolean redstoneStateDirty = true; - - public IGasHandler getExternalHandler(ForgeDirection direction) - { - IGasHandler con = GasUtil.getExternalGasHandler(getBundle().getWorld(), getLocation().getLocation(direction)); - return (con != null) && (!(con instanceof IConduitBundle)) ? con : null; - } - - public IGasHandler getTankContainer(BlockCoord bc) - { - return GasUtil.getGasHandler(getBundle().getWorld(), bc); - } - - public boolean canConnectToExternal(ForgeDirection direction, boolean ignoreDisabled) - { - IGasHandler h = getExternalHandler(direction); - if (h == null) { - return false; - } - return true; - } - - public Class<? extends IConduit> getBaseConduitType() - { - return IGasConduit.class; - } - - public boolean onNeighborBlockChange(Block blockId) - { - this.redstoneStateDirty = true; - return super.onNeighborBlockChange(blockId); - } - - public void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir) - { - this.extractionModes.put(dir, mode); - this.redstoneStateDirty = true; - } - - public RedstoneControlMode getExtractionRedstoneMode(ForgeDirection dir) - { - RedstoneControlMode res = (RedstoneControlMode)this.extractionModes.get(dir); - if (res == null) { - res = RedstoneControlMode.ON; - } - return res; - } - - public void setExtractionSignalColor(ForgeDirection dir, DyeColor col) - { - this.extractionColors.put(dir, col); - } - - public DyeColor getExtractionSignalColor(ForgeDirection dir) - { - DyeColor result = (DyeColor)this.extractionColors.get(dir); - if (result == null) { - return DyeColor.RED; - } - return result; - } - - public boolean canOutputToDir(ForgeDirection dir) - { - if ((isExtractingFromDir(dir)) || (getConnectionMode(dir) == ConnectionMode.DISABLED)) { - return false; - } - if (this.conduitConnections.contains(dir)) { - return true; - } - if (!this.externalConnections.contains(dir)) { - return false; - } - IGasHandler ext = getExternalHandler(dir); - if ((ext instanceof TileReservoir)) - { - TileReservoir tr = (TileReservoir)ext; - return (!tr.isMultiblock()) || (!tr.isAutoEject()); - } - return true; - } - - protected boolean autoExtractForDir(ForgeDirection dir) - { - if (!isExtractingFromDir(dir)) { - return false; - } - RedstoneControlMode mode = getExtractionRedstoneMode(dir); - if (mode == RedstoneControlMode.IGNORE) { - return true; - } - if (mode == RedstoneControlMode.NEVER) { - return false; - } - if (this.redstoneStateDirty) - { - this.externalRedstoneSignals.clear(); - this.redstoneStateDirty = false; - } - DyeColor col = getExtractionSignalColor(dir); - int signal = ConduitUtil.getInternalSignalForColor(getBundle(), col); - if ((RedstoneControlMode.isConditionMet(mode, signal)) && (mode != RedstoneControlMode.OFF)) { - return true; - } - return isConditionMetByExternalSignal(dir, mode, col); - } - - private boolean isConditionMetByExternalSignal(ForgeDirection dir, RedstoneControlMode mode, DyeColor col) - { - int externalSignal = 0; - if (col == DyeColor.RED) - { - Integer val = (Integer)this.externalRedstoneSignals.get(dir); - if (val == null) - { - TileEntity te = getBundle().getEntity(); - externalSignal = te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord); - this.externalRedstoneSignals.put(dir, Integer.valueOf(externalSignal)); - } - else - { - externalSignal = val.intValue(); - } - } - return RedstoneControlMode.isConditionMet(mode, externalSignal); - } - - public boolean isExtractingFromDir(ForgeDirection dir) - { - return getConnectionMode(dir) == ConnectionMode.INPUT; - } - - public void writeToNBT(NBTTagCompound nbtRoot) - { - super.writeToNBT(nbtRoot); - for (Map.Entry<ForgeDirection, RedstoneControlMode> entry : this.extractionModes.entrySet()) { - if (entry.getValue() != null) - { - short ord = (short)((RedstoneControlMode)entry.getValue()).ordinal(); - nbtRoot.setShort("extRM." + ((ForgeDirection)entry.getKey()).name(), ord); - } - } - for (Map.Entry<ForgeDirection, DyeColor> entry : this.extractionColors.entrySet()) { - if (entry.getValue() != null) - { - short ord = (short)((DyeColor)entry.getValue()).ordinal(); - nbtRoot.setShort("extSC." + ((ForgeDirection)entry.getKey()).name(), ord); - } - } - } - - public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) - { - super.readFromNBT(nbtRoot, nbtVersion); - for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - String key = "extRM." + dir.name(); - if (nbtRoot.hasKey(key)) - { - short ord = nbtRoot.getShort(key); - if ((ord >= 0) && (ord < RedstoneControlMode.values().length)) { - this.extractionModes.put(dir, RedstoneControlMode.values()[ord]); - } - } - key = "extSC." + dir.name(); - if (nbtRoot.hasKey(key)) - { - short ord = nbtRoot.getShort(key); - if ((ord >= 0) && (ord < DyeColor.values().length)) { - this.extractionColors.put(dir, DyeColor.values()[ord]); - } - } - } - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduit.java b/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduit.java deleted file mode 100644 index 7b8e36f498..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduit.java +++ /dev/null @@ -1,169 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.List; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import crazypants.enderio.conduit.AbstractConduitNetwork; -import crazypants.enderio.conduit.ConduitUtil; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.RaytraceResult; -import crazypants.enderio.tool.ToolUtil; -import crazypants.util.BlockCoord; - -public abstract class AbstractGasTankConduit - extends AbstractGasConduit -{ - protected ConduitGasTank tank = new ConduitGasTank(0); - protected boolean stateDirty = false; - protected long lastEmptyTick = 0L; - protected int numEmptyEvents = 0; - - public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) - { - if (player.getCurrentEquippedItem() == null) { - return false; - } - if (ToolUtil.isToolEquipped(player)) - { - if (!getBundle().getEntity().getWorldObj().isRemote) { - if ((res != null) && (res.component != null)) - { - ForgeDirection connDir = res.component.dir; - ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit); - if ((connDir == ForgeDirection.UNKNOWN) || (connDir == faceHit)) - { - if (getConnectionMode(faceHit) == ConnectionMode.DISABLED) - { - setConnectionMode(faceHit, getNextConnectionMode(faceHit)); - return true; - } - BlockCoord loc = getLocation().getLocation(faceHit); - IGasConduit n = (IGasConduit)ConduitUtil.getConduit(getBundle().getEntity().getWorldObj(), loc.x, loc.y, loc.z, IGasConduit.class); - if (n == null) { - return false; - } - if (!canJoinNeighbour(n)) { - return false; - } - if (!(n instanceof AbstractGasTankConduit)) { - return false; - } - AbstractGasTankConduit neighbour = (AbstractGasTankConduit)n; - if ((neighbour.getGasType() == null) || (getGasType() == null)) - { - GasStack type = getGasType(); - type = type != null ? type : neighbour.getGasType(); - neighbour.setGasTypeOnNetwork(neighbour, type); - setGasTypeOnNetwork(this, type); - } - return ConduitUtil.joinConduits(this, faceHit); - } - if (containsExternalConnection(connDir)) - { - setConnectionMode(connDir, getNextConnectionMode(connDir)); - } - else if (containsConduitConnection(connDir)) - { - GasStack curGasType = null; - if (getTankNetwork() != null) { - curGasType = getTankNetwork().getGasType(); - } - ConduitUtil.disconectConduits(this, connDir); - setGasType(curGasType); - } - } - } - return true; - } - return false; - } - - private void setGasTypeOnNetwork(AbstractGasTankConduit con, GasStack type) - { - AbstractConduitNetwork<?, ?> n = con.getNetwork(); - if (n != null) - { - AbstractGasTankConduitNetwork<?> network = (AbstractGasTankConduitNetwork)n; - network.setGasType(type); - } - } - - protected abstract boolean canJoinNeighbour(IGasConduit paramIGasConduit); - - public abstract AbstractGasTankConduitNetwork<? extends AbstractGasTankConduit> getTankNetwork(); - - public void setGasType(GasStack gasType) - { - if ((this.tank.getGas() != null) && (this.tank.getGas().isGasEqual(gasType))) { - return; - } - if (gasType != null) { - gasType = gasType.copy(); - } else if (this.tank.getGas() == null) { - return; - } - this.tank.setGas(gasType); - this.stateDirty = true; - } - - public ConduitGasTank getTank() - { - return this.tank; - } - - public GasStack getGasType() - { - GasStack result = null; - if (getTankNetwork() != null) { - result = getTankNetwork().getGasType(); - } - if (result == null) { - result = this.tank.getGas(); - } - return result; - } - - public boolean canOutputToDir(ForgeDirection dir) - { - if (super.canOutputToDir(dir)) - { - IGasHandler ext = getExternalHandler(dir); - return (ext != null) && (ext.canReceiveGas(dir.getOpposite(), this.tank.getGasType())); - } - return false; - } - - protected abstract void updateTank(); - - public void readFromNBT(NBTTagCompound nbtRoot, short nbtVersion) - { - super.readFromNBT(nbtRoot, nbtVersion); - updateTank(); - if (nbtRoot.hasKey("tank")) - { - GasStack gas = GasStack.readFromNBT(nbtRoot.getCompoundTag("tank")); - this.tank.setGas(gas); - } - else - { - this.tank.setGas(null); - } - } - - public void writeToNBT(NBTTagCompound nbtRoot) - { - super.writeToNBT(nbtRoot); - GasStack gt = getGasType(); - if (GasUtil.isGasValid(gt)) - { - updateTank(); - gt = gt.copy(); - gt.amount = this.tank.getStored(); - nbtRoot.setTag("tank", gt.write(new NBTTagCompound())); - } - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduitNetwork.java b/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduitNetwork.java deleted file mode 100644 index ec75d1319e..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/AbstractGasTankConduitNetwork.java +++ /dev/null @@ -1,73 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import mekanism.api.gas.GasStack; -import crazypants.enderio.conduit.AbstractConduitNetwork; - -public class AbstractGasTankConduitNetwork<T extends AbstractGasTankConduit> - extends AbstractConduitNetwork<IGasConduit, T> -{ - protected GasStack gasType; - - protected AbstractGasTankConduitNetwork(Class<T> cl) - { - super(cl); - } - - public GasStack getGasType() - { - return this.gasType; - } - - public Class<IGasConduit> getBaseConduitType() - { - return IGasConduit.class; - } - - public void addConduit(T con) - { - super.addConduit(con); - con.setGasType(this.gasType); - } - - public boolean setGasType(GasStack newType) - { - if ((this.gasType != null) && (this.gasType.isGasEqual(newType))) { - return false; - } - if (newType != null) - { - this.gasType = newType.copy(); - this.gasType.amount = 0; - } - else - { - this.gasType = null; - } - for (AbstractGasTankConduit conduit : this.conduits) { - conduit.setGasType(this.gasType); - } - return true; - } - - public boolean canAcceptGas(GasStack acceptable) - { - return areGassCompatable(this.gasType, acceptable); - } - - public static boolean areGassCompatable(GasStack a, GasStack b) - { - if ((a == null) || (b == null)) { - return true; - } - return a.isGasEqual(b); - } - - public int getTotalVolume() - { - int totalVolume = 0; - for (T con : this.conduits) { - totalVolume += con.getTank().getStored(); - } - return totalVolume; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/ConduitGasTank.java b/src/Java/miscutil/enderio/conduit/gas/ConduitGasTank.java deleted file mode 100644 index 3e944a2f2c..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/ConduitGasTank.java +++ /dev/null @@ -1,160 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTank; -import net.minecraft.nbt.NBTTagCompound; - -public class ConduitGasTank - extends GasTank -{ - private int capacity; - - ConduitGasTank(int capacity) - { - super(capacity); - this.capacity = capacity; - } - - public float getFilledRatio() - { - if (getStored() <= 0) { - return 0.0F; - } - if (getMaxGas() <= 0) { - return -1.0F; - } - float res = getStored() / getMaxGas(); - return res; - } - - public boolean isFull() - { - return getStored() >= getMaxGas(); - } - - public void setAmount(int amount) - { - if (this.stored != null) { - this.stored.amount = amount; - } - } - - public int getAvailableSpace() - { - return getMaxGas() - getStored(); - } - - public void addAmount(int amount) - { - setAmount(getStored() + amount); - } - - public int getMaxGas() - { - return this.capacity; - } - - public void setCapacity(int capacity) - { - this.capacity = capacity; - if (getStored() > capacity) { - setAmount(capacity); - } - } - - public int receive(GasStack resource, boolean doReceive) - { - if ((resource == null) || (resource.getGas().getID() < 0)) { - return 0; - } - if ((this.stored == null) || (this.stored.getGas().getID() < 0)) - { - if (resource.amount <= this.capacity) - { - if (doReceive) { - setGas(resource.copy()); - } - return resource.amount; - } - if (doReceive) - { - this.stored = resource.copy(); - this.stored.amount = this.capacity; - } - return this.capacity; - } - if (!this.stored.isGasEqual(resource)) { - return 0; - } - int space = this.capacity - this.stored.amount; - if (resource.amount <= space) - { - if (doReceive) { - addAmount(resource.amount); - } - return resource.amount; - } - if (doReceive) { - this.stored.amount = this.capacity; - } - return space; - } - - public GasStack draw(int maxDrain, boolean doDraw) - { - if ((this.stored == null) || (this.stored.getGas().getID() < 0)) { - return null; - } - if (this.stored.amount <= 0) { - return null; - } - int used = maxDrain; - if (this.stored.amount < used) { - used = this.stored.amount; - } - if (doDraw) { - addAmount(-used); - } - GasStack drained = new GasStack(this.stored.getGas().getID(), used); - if (this.stored.amount < 0) { - this.stored.amount = 0; - } - return drained; - } - - public String getGasName() - { - return this.stored != null ? this.stored.getGas().getLocalizedName() : null; - } - - public boolean containsValidGas() - { - return GasUtil.isGasValid(this.stored); - } - - public NBTTagCompound write(NBTTagCompound nbt) - { - if (containsValidGas()) { - this.stored.write(nbt); - } else { - nbt.setBoolean("emptyGasTank", true); - } - return nbt; - } - - public void read(NBTTagCompound nbt) - { - if (!nbt.hasKey("emptyGasTank")) - { - GasStack gas = GasStack.readFromNBT(nbt); - if (gas != null) { - setGas(gas); - } - } - } - - public boolean isEmpty() - { - return (this.stored == null) || (this.stored.amount == 0); - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/GasConduit.java b/src/Java/miscutil/enderio/conduit/gas/GasConduit.java deleted file mode 100644 index bac24cabfd..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/GasConduit.java +++ /dev/null @@ -1,258 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.HashMap; -import java.util.Map; - -import mekanism.api.gas.Gas; -import mekanism.api.gas.GasStack; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import crazypants.enderio.EnderIO; -import crazypants.enderio.conduit.AbstractConduitNetwork; -import crazypants.enderio.conduit.ConnectionMode; -import crazypants.enderio.conduit.IConduit; -import crazypants.enderio.conduit.geom.CollidableComponent; -import crazypants.enderio.config.Config; -import crazypants.render.IconUtil; -import crazypants.util.BlockCoord; - -public class GasConduit - extends AbstractGasTankConduit -{ - public static final int CONDUIT_VOLUME = 1000; - public static final String ICON_KEY = "enderio:gasConduit"; - public static final String ICON_CORE_KEY = "enderio:gasConduitCore"; - public static final String ICON_EXTRACT_KEY = "enderio:gasConduitInput"; - public static final String ICON_INSERT_KEY = "enderio:gasConduitOutput"; - public static final String ICON_EMPTY_EDGE = "enderio:gasConduitEdge"; - static final Map<String, IIcon> ICONS = new HashMap(); - private GasConduitNetwork network; - - @SideOnly(Side.CLIENT) - public static void initIcons() - { - IconUtil.addIconProvider(new IconUtil.IIconProvider() - { - public void registerIcons(IIconRegister register) - { - GasConduit.ICONS.put("enderio:gasConduit", register.registerIcon("enderio:gasConduit")); - GasConduit.ICONS.put("enderio:gasConduitCore", register.registerIcon("enderio:gasConduitCore")); - GasConduit.ICONS.put("enderio:gasConduitInput", register.registerIcon("enderio:gasConduitInput")); - GasConduit.ICONS.put("enderio:gasConduitOutput", register.registerIcon("enderio:gasConduitOutput")); - GasConduit.ICONS.put("enderio:gasConduitEdge", register.registerIcon("enderio:gasConduitEdge")); - } - - public int getTextureType() - { - return 0; - } - }); - } - - private long ticksSinceFailedExtract = 0L; - public static final int MAX_EXTRACT_PER_TICK = Config.gasConduitExtractRate; - public static final int MAX_IO_PER_TICK = Config.gasConduitMaxIoRate; - - public GasConduit() - { - updateTank(); - } - - public void updateEntity(World world) - { - super.updateEntity(world); - if (world.isRemote) { - return; - } - doExtract(); - if (this.stateDirty) - { - getBundle().dirty(); - this.stateDirty = false; - } - } - - private void doExtract() - { - BlockCoord loc = getLocation(); - if (!hasConnectionMode(ConnectionMode.INPUT)) { - return; - } - if (this.network == null) { - return; - } - this.ticksSinceFailedExtract += 1L; - if ((this.ticksSinceFailedExtract > 25L) && (this.ticksSinceFailedExtract % 10L != 0L)) { - return; - } - Gas f = this.tank.getGas() == null ? null : this.tank.getGas().getGas(); - for (ForgeDirection dir : this.externalConnections) { - if ((autoExtractForDir(dir)) && - (this.network.extractFrom(this, dir, MAX_EXTRACT_PER_TICK))) { - this.ticksSinceFailedExtract = 0L; - } - } - } - - protected void updateTank() - { - this.tank.setCapacity(1000); - if (this.network != null) { - this.network.updateConduitVolumes(); - } - } - - public ItemStack createItem() - { - return new ItemStack(EnderIO.itemGasConduit); - } - - public AbstractConduitNetwork<?, ?> getNetwork() - { - return this.network; - } - - public boolean setNetwork(AbstractConduitNetwork<?, ?> network) - { - if (network == null) - { - this.network = null; - return true; - } - if (!(network instanceof GasConduitNetwork)) { - return false; - } - GasConduitNetwork n = (GasConduitNetwork)network; - if (this.tank.getGas() == null) { - this.tank.setGas(n.getGasType() == null ? null : n.getGasType().copy()); - } else if (n.getGasType() == null) { - n.setGasType(this.tank.getGas()); - } else if (!this.tank.getGas().isGasEqual(n.getGasType())) { - return false; - } - this.network = n; - return true; - } - - public boolean canConnectToConduit(ForgeDirection direction, IConduit con) - { - if (!super.canConnectToConduit(direction, con)) { - return false; - } - if (!(con instanceof GasConduit)) { - return false; - } - if ((getGasType() != null) && (((GasConduit)con).getGasType() == null)) { - return false; - } - return GasConduitNetwork.areGassCompatable(getGasType(), ((GasConduit)con).getGasType()); - } - - public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) - { - super.setConnectionMode(dir, mode); - refreshInputs(dir); - } - - private void refreshInputs(ForgeDirection dir) - { - if (this.network == null) { - return; - } - GasOutput lo = new GasOutput(getLocation().getLocation(dir), dir.getOpposite()); - this.network.removeInput(lo); - if ((getConnectionMode(dir).acceptsOutput()) && (containsExternalConnection(dir))) { - this.network.addInput(lo); - } - } - - public void externalConnectionAdded(ForgeDirection fromDirection) - { - super.externalConnectionAdded(fromDirection); - refreshInputs(fromDirection); - } - - public void externalConnectionRemoved(ForgeDirection fromDirection) - { - super.externalConnectionRemoved(fromDirection); - refreshInputs(fromDirection); - } - - public IIcon getTextureForState(CollidableComponent component) - { - if (component.dir == ForgeDirection.UNKNOWN) { - return (IIcon)ICONS.get("enderio:gasConduitCore"); - } - return (IIcon)ICONS.get("enderio:gasConduit"); - } - - public IIcon getTextureForInputMode() - { - return (IIcon)ICONS.get("enderio:gasConduitInput"); - } - - public IIcon getTextureForOutputMode() - { - return (IIcon)ICONS.get("enderio:gasConduitOutput"); - } - - public IIcon getNotSetEdgeTexture() - { - return (IIcon)ICONS.get("enderio:gasConduitEdge"); - } - - public IIcon getTransmitionTextureForState(CollidableComponent component) - { - if ((isActive()) && (this.tank.containsValidGas())) { - return this.tank.getGas().getGas().getIcon(); - } - return null; - } - - public int receiveGas(ForgeDirection from, GasStack resource) - { - if ((this.network == null) || (!getConnectionMode(from).acceptsInput())) { - return 0; - } - return this.network.fill(from, resource, true); - } - - public GasStack drawGas(ForgeDirection from, int maxDrain) - { - if ((this.network == null) || (!getConnectionMode(from).acceptsOutput())) { - return null; - } - return this.network.drain(from, maxDrain, true); - } - - public boolean canReceiveGas(ForgeDirection from, Gas gas) - { - if (this.network == null) { - return false; - } - return (getConnectionMode(from).acceptsInput()) && (GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0))); - } - - public boolean canDrawGas(ForgeDirection from, Gas gas) - { - if (this.network == null) { - return false; - } - return (getConnectionMode(from).acceptsOutput()) && (GasConduitNetwork.areGassCompatable(getGasType(), new GasStack(gas, 0))); - } - - protected boolean canJoinNeighbour(IGasConduit n) - { - return n instanceof GasConduit; - } - - public AbstractGasTankConduitNetwork<? extends AbstractGasTankConduit> getTankNetwork() - { - return this.network; - } -} diff --git a/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java b/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java deleted file mode 100644 index a93a418627..0000000000 --- a/src/Java/miscutil/enderio/conduit/gas/GasConduitNetwork.java +++ /dev/null @@ -1,317 +0,0 @@ -package miscutil.enderio.conduit.gas; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.IGasHandler; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.gameevent.TickEvent; -import crazypants.enderio.conduit.ConduitNetworkTickHandler; -import crazypants.enderio.conduit.IConduit; -import crazypants.util.BlockCoord; - -public class GasConduitNetwork - extends AbstractGasTankConduitNetwork<GasConduit> -{ - private final ConduitGasTank tank = new ConduitGasTank(0); - private final Set<GasOutput> outputs = new HashSet(); - private Iterator<GasOutput> outputIterator; - private int ticksActiveUnsynced; - private boolean lastSyncedActive = false; - private int lastSyncedVolume = -1; - private long timeAtLastApply; - private final InnerTickHandler tickHandler = new InnerTickHandler(); - - public GasConduitNetwork() - { - super(GasConduit.class); - } - - public Class<IGasConduit> getBaseConduitType() - { - return IGasConduit.class; - } - - public void addConduit(GasConduit con) - { - this.tank.setCapacity(this.tank.getMaxGas() + 1000); - if (con.getTank().containsValidGas()) { - this.tank.addAmount(con.getTank().getStored()); - } - for (ForgeDirection dir : con.getExternalConnections()) { - if (con.getConnectionMode(dir).acceptsOutput()) { - this.outputs.add(new GasOutput(con.getLocation().getLocation(dir), dir.getOpposite())); - } - } - this.outputIterator = null; - super.addConduit(con); - } - - public boolean setGasType(GasStack newType) - { - if (super.setGasType(newType)) - { - GasStack ft = getGasType(); - this.tank.setGas(ft == null ? null : ft.copy()); - return true; - } - return false; - } - - public void destroyNetwork() - { - setConduitVolumes(); - this.outputs.clear(); - super.destroyNetwork(); - } - - private void setConduitVolumes() - { - GasStack gasPerConduit; - int leftOvers; - if ((this.tank.containsValidGas()) && (!this.conduits.isEmpty())) - { - gasPerConduit = this.tank.getGas().copy(); - int numCons = this.conduits.size(); - leftOvers = gasPerConduit.amount % numCons; - gasPerConduit.amount /= numCons; - for (GasConduit con : this.conduits) - { - GasStack f = gasPerConduit.copy(); - if (leftOvers > 0) - { - f.amount += 1; - leftOvers--; - } - con.getTank().setGas(f); - BlockCoord bc = con.getLocation(); - con.getBundle().getEntity().getWorldObj().markTileEntityChunkModified(bc.x, bc.y, bc.z, con.getBundle().getEntity()); - } - } - } - - pub |
