Fixed Digital Miner, fixed energy upgrades not affecting usage of Chemical Washers/Electrolytic Separators/Chemical Infusers/Rotary Condensentrators, added "dump excess" to electrolytic separator

This commit is contained in:
Aidan C. Brady 2015-03-19 17:22:31 -04:00
parent 9c6708660b
commit 3b96fe4a4c
15 changed files with 137 additions and 87 deletions

View file

@ -51,7 +51,7 @@ public class GuiChemicalInfuser extends GuiMekanism
if(tileEntity.getRecipe() != null) if(tileEntity.getRecipe() != null)
{ {
usage = tileEntity.getUpgradedUsage(tileEntity.getRecipe())*tileEntity.BASE_ENERGY_USAGE; usage = tileEntity.getUpgradedUsage(tileEntity.getRecipe())*MekanismUtils.getPureEnergyPerTick(tileEntity, tileEntity.BASE_ENERGY_USAGE);
} }
String multiplier = MekanismUtils.getEnergyDisplay(usage); String multiplier = MekanismUtils.getEnergyDisplay(usage);

View file

@ -53,7 +53,7 @@ public class GuiChemicalWasher extends GuiMekanism
@Override @Override
public List<String> getInfo() public List<String> getInfo()
{ {
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.BASE_ENERGY_USAGE*tileEntity.getUpgradedUsage()); String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getPureEnergyPerTick(tileEntity, tileEntity.BASE_ENERGY_USAGE)*tileEntity.getUpgradedUsage());
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
} }
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png")));

View file

@ -4,38 +4,39 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.api.MekanismConfig.general;
import mekanism.api.gas.GasTank; import mekanism.api.gas.GasTank;
import mekanism.api.util.ListUtils; import mekanism.api.util.ListUtils;
import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiEnergyInfo;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiFluidGauge;
import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler;
import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge;
import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiGauge;
import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress;
import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler;
import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler;
import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiProgress.ProgressBar;
import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType; import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.gui.element.GuiUpgradeTab;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerElectrolyticSeparator; import mekanism.common.inventory.container.ContainerElectrolyticSeparator;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityElectrolyticSeparator; import mekanism.common.tile.TileEntityElectrolyticSeparator;
import mekanism.common.tile.TileEntityGasTank;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTank;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiElectrolyticSeparator extends GuiMekanism public class GuiElectrolyticSeparator extends GuiMekanism
{ {
@ -56,7 +57,7 @@ public class GuiElectrolyticSeparator extends GuiMekanism
if(tileEntity.getRecipe() != null) if(tileEntity.getRecipe() != null)
{ {
usage = tileEntity.getUpgradedUsage(tileEntity.getRecipe())*tileEntity.getRecipe().extraEnergy; usage = tileEntity.getUpgradedUsage(tileEntity.getRecipe())*MekanismUtils.getPureEnergyPerTick(tileEntity, tileEntity.getRecipe().extraEnergy);
} }
String multiplier = MekanismUtils.getEnergyDisplay(usage); String multiplier = MekanismUtils.getEnergyDisplay(usage);
@ -132,11 +133,11 @@ public class GuiElectrolyticSeparator extends GuiMekanism
{ {
fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040);
String name = tileEntity.dumpLeft ? "Dumping..." : tileEntity.leftTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.leftTank.getGas().getGas().getLocalizedName(); String name = chooseByMode(tileEntity.dumpLeft, MekanismUtils.localize("gui.idle"), MekanismUtils.localize("gui.dumping"), MekanismUtils.localize("gui.dumping_excess"));
fontRendererObj.drawString(name, 21, 73, 0x404040); renderScaledText(name, 21, 73, 0x404040, 66);
name = tileEntity.dumpRight ? "Dumping..." : tileEntity.rightTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.rightTank.getGas().getGas().getLocalizedName(); name = chooseByMode(tileEntity.dumpRight, MekanismUtils.localize("gui.idle"), MekanismUtils.localize("gui.dumping"), MekanismUtils.localize("gui.dumping_excess"));
fontRendererObj.drawString(name, 156-fontRendererObj.getStringWidth(name), 73, 0x404040); renderScaledText(name, 156-(int)(fontRendererObj.getStringWidth(name)*getNeededScale(name, 66)), 73, 0x404040, 66);
super.drawGuiContainerForegroundLayer(mouseX, mouseY); super.drawGuiContainerForegroundLayer(mouseX, mouseY);
} }
@ -150,12 +151,30 @@ public class GuiElectrolyticSeparator extends GuiMekanism
int guiHeight = (height - ySize) / 2; int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt = tileEntity.dumpLeft ? 60 : 52; int displayInt = chooseByMode(tileEntity.dumpLeft, 52, 60, 68);
drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, displayInt, 8, 8); drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, displayInt, 8, 8);
displayInt = tileEntity.dumpRight ? 60 : 52; displayInt = chooseByMode(tileEntity.dumpRight, 52, 60, 68);
drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8);
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
} }
private <T> T chooseByMode(TileEntityGasTank.GasMode dumping, T idleOption, T dumpingOption, T dumpingExcessOption)
{
if(dumping.equals(TileEntityGasTank.GasMode.IDLE))
{
return idleOption;
}
else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING))
{
return dumpingOption;
}
else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS))
{
return dumpingExcessOption;
}
return idleOption; //should not happen;
}
} }

View file

@ -2,8 +2,6 @@ package mekanism.client.gui;
import java.util.ArrayList; import java.util.ArrayList;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import mekanism.api.Coord4D; import mekanism.api.Coord4D;
import mekanism.client.sound.SoundHandler; import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
@ -13,8 +11,12 @@ import mekanism.common.tile.TileEntityGasTank;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiGasTank extends GuiMekanism public class GuiGasTank extends GuiMekanism
{ {
@ -86,17 +88,17 @@ public class GuiGasTank extends GuiMekanism
} }
} }
private <T> T chooseByMode(TileEntityGasTank.Mode dumping, T idleOption, T dumpingOption, T dumpingExcessOption) private <T> T chooseByMode(TileEntityGasTank.GasMode dumping, T idleOption, T dumpingOption, T dumpingExcessOption)
{ {
if(dumping.equals(TileEntityGasTank.Mode.IDLE)) if(dumping.equals(TileEntityGasTank.GasMode.IDLE))
{ {
return idleOption; return idleOption;
} }
else if(dumping.equals(TileEntityGasTank.Mode.DUMPING)) else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING))
{ {
return dumpingOption; return dumpingOption;
} }
else if(dumping.equals(TileEntityGasTank.Mode.DUMPING_EXCESS)) else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS))
{ {
return dumpingExcessOption; return dumpingExcessOption;
} }

View file

@ -38,6 +38,20 @@ public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper
tileEntity = tile; tileEntity = tile;
} }
public float getNeededScale(String text, int maxX)
{
int length = fontRendererObj.getStringWidth(text);
if(length <= maxX)
{
return 1;
}
else {
return (float)maxX/length;
}
}
/** returns scale */
public void renderScaledText(String text, int x, int y, int color, int maxX) public void renderScaledText(String text, int x, int y, int color, int maxX)
{ {
int length = fontRendererObj.getStringWidth(text); int length = fontRendererObj.getStringWidth(text);

View file

@ -59,7 +59,7 @@ public class GuiRotaryCondensentrator extends GuiMekanism
@Override @Override
public List<String> getInfo() public List<String> getInfo()
{ {
String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.BASE_ENERGY_USAGE*tileEntity.getUpgradedUsage()); String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getPureEnergyPerTick(tileEntity, tileEntity.BASE_ENERGY_USAGE)*tileEntity.getUpgradedUsage());
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
} }
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png")));

View file

@ -119,10 +119,10 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
ChemicalInfuserRecipe recipe = getRecipe(); ChemicalInfuserRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this)) if(canOperate(recipe) && getEnergy() >= MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE) && MekanismUtils.canFunction(this))
{ {
setActive(true); setActive(true);
setEnergy(getEnergy() - BASE_ENERGY_USAGE); setEnergy(getEnergy() - MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE));
operate(recipe); operate(recipe);
} }
@ -167,7 +167,7 @@ public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock impl
} }
possibleProcess = Math.min(centerTank.getNeeded()/recipe.recipeOutput.output.amount, possibleProcess); possibleProcess = Math.min(centerTank.getNeeded()/recipe.recipeOutput.output.amount, possibleProcess);
possibleProcess = Math.min((int)(getEnergy()/BASE_ENERGY_USAGE), possibleProcess); possibleProcess = Math.min((int)(getEnergy()/MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE)), possibleProcess);
return possibleProcess; return possibleProcess;
} }

View file

@ -123,13 +123,13 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
WasherRecipe recipe = getRecipe(); WasherRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this)) if(canOperate(recipe) && getEnergy() >= MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE) && MekanismUtils.canFunction(this))
{ {
setActive(true); setActive(true);
int operations = operate(recipe); int operations = operate(recipe);
setEnergy(getEnergy() - BASE_ENERGY_USAGE*operations); setEnergy(getEnergy() - MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE)*operations);
} }
else { else {
if(prevEnergy >= getEnergy()) if(prevEnergy >= getEnergy())
@ -264,7 +264,7 @@ public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock imple
{ {
int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED));
possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess); possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess);
possibleProcess = Math.min((int)(getEnergy()/BASE_ENERGY_USAGE), possibleProcess); possibleProcess = Math.min((int)(getEnergy()/MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE)), possibleProcess);
return Math.min(fluidTank.getFluidAmount()/WATER_USAGE, possibleProcess); return Math.min(fluidTank.getFluidAmount()/WATER_USAGE, possibleProcess);
} }

View file

@ -91,10 +91,12 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
public boolean doPull = false; public boolean doPull = false;
public ItemStack missingStack = null; public ItemStack missingStack = null;
public int BASE_DELAY = 80;
public int delay; public int delay;
public int delayLength; public int delayLength = BASE_DELAY;
public int clientToMine; public int clientToMine;
@ -275,9 +277,9 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
{ {
oresToMine.remove(chunk); oresToMine.remove(chunk);
} }
delay = getDelay();
} }
delay = getDelay();
} }
else { else {
if(prevEnergy >= getEnergy()) if(prevEnergy >= getEnergy())
@ -1470,7 +1472,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
switch(upgrade) switch(upgrade)
{ {
case SPEED: case SPEED:
delayLength = MekanismUtils.getTicks(this, 80); delayLength = MekanismUtils.getTicks(this, BASE_DELAY);
case ENERGY: case ENERGY:
energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE);
maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY);

View file

@ -18,8 +18,8 @@ import mekanism.api.gas.ITubeConnection;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.Upgrade; import mekanism.common.Upgrade;
import mekanism.common.Upgrade.IUpgradeInfoHandler; import mekanism.common.Upgrade.IUpgradeInfoHandler;
import mekanism.common.base.ITankManager;
import mekanism.common.base.ISustainedData; import mekanism.common.base.ISustainedData;
import mekanism.common.base.ITankManager;
import mekanism.common.base.IUpgradeTile; import mekanism.common.base.IUpgradeTile;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.network.PacketTileEntity.TileEntityMessage;
@ -28,6 +28,7 @@ import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.FluidInput; import mekanism.common.recipe.inputs.FluidInput;
import mekanism.common.recipe.machines.SeparatorRecipe; import mekanism.common.recipe.machines.SeparatorRecipe;
import mekanism.common.recipe.outputs.ChemicalPairOutput; import mekanism.common.recipe.outputs.ChemicalPairOutput;
import mekanism.common.tile.TileEntityGasTank.GasMode;
import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.tile.component.TileComponentUpgrade;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
import mekanism.common.util.FluidContainerUtils; import mekanism.common.util.FluidContainerUtils;
@ -71,10 +72,10 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
public int output = 256; public int output = 256;
/** The type of gas this block is outputting. */ /** The type of gas this block is outputting. */
public boolean dumpLeft = false; public GasMode dumpLeft = GasMode.IDLE;
/** Type type of gas this block is dumping. */ /** Type type of gas this block is dumping. */
public boolean dumpRight = false; public GasMode dumpRight = GasMode.IDLE;
public boolean isActive = false; public boolean isActive = false;
@ -143,13 +144,13 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
SeparatorRecipe recipe = getRecipe(); SeparatorRecipe recipe = getRecipe();
if(canOperate(recipe) && getEnergy() >= recipe.extraEnergy) if(canOperate(recipe) && getEnergy() >= MekanismUtils.getPureEnergyPerTick(this, recipe.extraEnergy))
{ {
setActive(true); setActive(true);
int operations = operate(recipe); int operations = operate(recipe);
setEnergy(getEnergy() - recipe.extraEnergy*operations); setEnergy(getEnergy() - MekanismUtils.getPureEnergyPerTick(this, recipe.extraEnergy)*operations);
} }
else { else {
setActive(false); setActive(false);
@ -159,7 +160,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
if(leftTank.getGas() != null) if(leftTank.getGas() != null)
{ {
if(!dumpLeft) if(dumpLeft != GasMode.DUMPING)
{ {
GasStack toSend = new GasStack(leftTank.getGas().getGas(), Math.min(leftTank.getStored(), output)); GasStack toSend = new GasStack(leftTank.getGas().getGas(), Math.min(leftTank.getStored(), output));
@ -173,7 +174,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
} }
} }
} }
else { else if(dumpLeft == GasMode.DUMPING)
{
leftTank.draw(dumpAmount, true); leftTank.draw(dumpAmount, true);
if(worldObj.rand.nextInt(3) == 2) if(worldObj.rand.nextInt(3) == 2)
@ -181,11 +183,21 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this))); Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this)));
} }
} }
if(dumpRight == GasMode.DUMPING_EXCESS && leftTank.getNeeded() < output)
{
leftTank.draw(output, true);
if(worldObj.rand.nextInt(3) == 2)
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this)));
}
}
} }
if(rightTank.getGas() != null) if(rightTank.getGas() != null)
{ {
if(!dumpRight) if(dumpRight != GasMode.DUMPING)
{ {
GasStack toSend = new GasStack(rightTank.getGas().getGas(), Math.min(rightTank.getStored(), output)); GasStack toSend = new GasStack(rightTank.getGas().getGas(), Math.min(rightTank.getStored(), output));
@ -199,7 +211,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
} }
} }
} }
else { else if(dumpRight == GasMode.DUMPING)
{
rightTank.draw(dumpAmount, true); rightTank.draw(dumpAmount, true);
if(worldObj.rand.nextInt(3) == 2) if(worldObj.rand.nextInt(3) == 2)
@ -207,6 +220,16 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(1, new ArrayList())), new Range4D(Coord4D.get(this))); Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(1, new ArrayList())), new Range4D(Coord4D.get(this)));
} }
} }
if(dumpRight == GasMode.DUMPING_EXCESS && rightTank.getNeeded() < output)
{
rightTank.draw(output, true);
if(worldObj.rand.nextInt(3) == 2)
{
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getParticlePacket(0, new ArrayList())), new Range4D(Coord4D.get(this)));
}
}
} }
} }
@ -227,7 +250,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
} }
possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess); possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess);
possibleProcess = Math.min((int)(getEnergy()/recipe.extraEnergy), possibleProcess); possibleProcess = Math.min((int)(getEnergy()/MekanismUtils.getPureEnergyPerTick(this, recipe.extraEnergy)), possibleProcess);
return Math.min(fluidTank.getFluidAmount()/recipe.recipeInput.ingredient.amount, possibleProcess); return Math.min(fluidTank.getFluidAmount()/recipe.recipeInput.ingredient.amount, possibleProcess);
} }
@ -378,11 +401,11 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
if(type == 0) if(type == 0)
{ {
dumpLeft ^= true; dumpLeft = GasMode.values()[dumpLeft.ordinal() == GasMode.values().length-1 ? 0 : dumpLeft.ordinal()+1];
} }
else if(type == 1) else if(type == 1)
{ {
dumpRight ^= true; dumpRight = GasMode.values()[dumpRight.ordinal() == GasMode.values().length-1 ? 0 : dumpRight.ordinal()+1];
} }
return; return;
@ -418,8 +441,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
rightTank.setGas(null); rightTank.setGas(null);
} }
dumpLeft = dataStream.readBoolean(); dumpLeft = GasMode.values()[dataStream.readInt()];
dumpRight = dataStream.readBoolean(); dumpRight = GasMode.values()[dataStream.readInt()];
isActive = dataStream.readBoolean(); isActive = dataStream.readBoolean();
} }
else if(type == 1) else if(type == 1)
@ -465,8 +488,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
data.add(false); data.add(false);
} }
data.add(dumpLeft); data.add(dumpLeft.ordinal());
data.add(dumpRight); data.add(dumpRight.ordinal());
data.add(isActive); data.add(isActive);
return data; return data;
@ -493,8 +516,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
leftTank.read(nbtTags.getCompoundTag("leftTank")); leftTank.read(nbtTags.getCompoundTag("leftTank"));
rightTank.read(nbtTags.getCompoundTag("rightTank")); rightTank.read(nbtTags.getCompoundTag("rightTank"));
dumpLeft = nbtTags.getBoolean("dumpLeft"); dumpLeft = GasMode.values()[nbtTags.getInteger("dumpLeft")];
dumpRight = nbtTags.getBoolean("dumpRight"); dumpRight = GasMode.values()[nbtTags.getInteger("dumpRight")];
} }
@Override @Override
@ -510,8 +533,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound())); nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound()));
nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound())); nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound()));
nbtTags.setBoolean("dumpLeft", dumpLeft); nbtTags.setInteger("dumpLeft", dumpLeft.ordinal());
nbtTags.setBoolean("dumpRight", dumpRight); nbtTags.setInteger("dumpRight", dumpRight.ordinal());
} }
@Override @Override

View file

@ -27,7 +27,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl
{ {
public enum Mode public enum GasMode
{ {
IDLE, IDLE,
DUMPING, DUMPING,
@ -42,7 +42,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
/** How fast this tank can output gas. */ /** How fast this tank can output gas. */
public int output = 256; public int output = 256;
public Mode dumping; public GasMode dumping;
public int currentGasAmount; public int currentGasAmount;
@ -54,7 +54,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
super("GasTank"); super("GasTank");
inventory = new ItemStack[2]; inventory = new ItemStack[2];
dumping = Mode.IDLE; dumping = GasMode.IDLE;
controlType = RedstoneControl.DISABLED; controlType = RedstoneControl.DISABLED;
} }
@ -71,7 +71,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true); gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true);
} }
if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this)) if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this) && dumping != GasMode.DUMPING)
{ {
GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output)); GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), output));
@ -86,12 +86,12 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
} }
} }
if(!worldObj.isRemote && dumping.equals(Mode.DUMPING)) if(!worldObj.isRemote && dumping == GasMode.DUMPING)
{ {
gasTank.draw(8, true); gasTank.draw(8, true);
} }
if(!worldObj.isRemote && dumping.equals(Mode.DUMPING_EXCESS) && gasTank.getNeeded() < output) if(!worldObj.isRemote && dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < output)
{ {
gasTank.draw(output, true); gasTank.draw(output, true);
} }
@ -184,7 +184,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
if(type == 0) if(type == 0)
{ {
int index = (dumping.ordinal() + 1)%dumping.values().length; int index = (dumping.ordinal() + 1)%dumping.values().length;
dumping = Mode.values()[index]; dumping = GasMode.values()[index];
} }
for(EntityPlayer player : playersUsing) for(EntityPlayer player : playersUsing)
@ -205,7 +205,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
gasTank.setGas(null); gasTank.setGas(null);
} }
dumping = Mode.values()[dataStream.readInt()]; dumping = GasMode.values()[dataStream.readInt()];
controlType = RedstoneControl.values()[dataStream.readInt()]; controlType = RedstoneControl.values()[dataStream.readInt()];
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
@ -217,22 +217,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
super.readFromNBT(nbtTags); super.readFromNBT(nbtTags);
gasTank.read(nbtTags.getCompoundTag("gasTank")); gasTank.read(nbtTags.getCompoundTag("gasTank"));
dumping = GasMode.values()[nbtTags.getInteger("dumping")];
if(nbtTags.hasKey("dumpingMode"))
{
dumping = Mode.valueOf(nbtTags.getString("dumpingMode"));
}
else {
boolean dumpingBool = nbtTags.getBoolean("dumping");
if(dumpingBool)
{
dumping = Mode.DUMPING;
}
else {
dumping = Mode.IDLE;
}
}
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
} }
@ -243,7 +228,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
super.writeToNBT(nbtTags); super.writeToNBT(nbtTags);
nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound()));
nbtTags.setString("dumpingMode", dumping.name()); nbtTags.setInteger("dumping", dumping.ordinal());
nbtTags.setInteger("controlType", controlType.ordinal()); nbtTags.setInteger("controlType", controlType.ordinal());
} }

View file

@ -111,7 +111,7 @@ public class TileEntityPRC extends TileEntityBasicMachine<PressurizedInput, Pres
if((operatingTicks+1) < ticksRequired) if((operatingTicks+1) < ticksRequired)
{ {
operatingTicks++; operatingTicks++;
electricityStored -= energyPerTick; electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy);
} }
else if((operatingTicks+1) >= ticksRequired && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy)) else if((operatingTicks+1) >= ticksRequired && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy))
{ {

View file

@ -278,14 +278,14 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
} }
} }
if(getEnergy() >= BASE_ENERGY_USAGE && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) if(getEnergy() >= MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE) && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid()))))
{ {
int usage = getUpgradedUsage(); int operations = getUpgradedUsage();
setActive(true); setActive(true);
gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), usage), true); gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), operations), true);
fluidTank.drain(usage, true); fluidTank.drain(operations, true);
setEnergy(getEnergy() - BASE_ENERGY_USAGE*usage); setEnergy(getEnergy() - MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE)*operations);
} }
else { else {
if(prevEnergy >= getEnergy()) if(prevEnergy >= getEnergy())
@ -311,7 +311,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
possibleProcess = Math.min(Math.min(fluidTank.getFluidAmount(), gasTank.getNeeded()), possibleProcess); possibleProcess = Math.min(Math.min(fluidTank.getFluidAmount(), gasTank.getNeeded()), possibleProcess);
} }
possibleProcess = Math.min((int)(getEnergy()/BASE_ENERGY_USAGE), possibleProcess); possibleProcess = Math.min((int)(getEnergy()/MekanismUtils.getPureEnergyPerTick(this, BASE_ENERGY_USAGE)), possibleProcess);
return possibleProcess; return possibleProcess;
} }

View file

@ -596,7 +596,12 @@ public final class MekanismUtils
*/ */
public static double getEnergyPerTick(IUpgradeTile mgmt, double def) public static double getEnergyPerTick(IUpgradeTile mgmt, double def)
{ {
return def * Math.pow(general.maxUpgradeMultiplier, (2*mgmt.getComponent().getUpgrades(Upgrade.SPEED)-(float)mgmt.getComponent().getUpgrades(Upgrade.ENERGY))/(float)Upgrade.SPEED.getMax()); return def * Math.pow(general.maxUpgradeMultiplier, (2*mgmt.getComponent().getUpgrades(Upgrade.SPEED)-(float)mgmt.getComponent().getUpgrades(Upgrade.ENERGY))/(float)Upgrade.ENERGY.getMax());
}
public static double getPureEnergyPerTick(IUpgradeTile mgmt, double def)
{
return def * Math.pow(general.maxUpgradeMultiplier, -(float)mgmt.getComponent().getUpgrades(Upgrade.ENERGY)/(float)Upgrade.ENERGY.getMax());
} }
/** /**

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB