Merge branch 'development' of https://github.com/aidancbrady/Mekanism into development

This commit is contained in:
Aidan Brady committed 2014-01-02 13:00:15 -05:00
commit 00bbb9d5c4
25 files changed
+132 -1066

No files matched your search

@@ -1,84 +0,0 @@
package mekanism.api;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
/**
* An input of one fluid and one gas for the Chemical Combiner.
* @author unpairedbracket
*
*/
public class ChemicalCombinerInput
{
/** The gas of this chemical combiner input */
public GasStack gas;
/** The fluid of this chemical combiner input */
public FluidStack fluid;
/**
* Creates a chemical input with two defined gasses of the Chemical Infuser.
* @param gas - gas
* @param fluid - fluid
*/
public ChemicalCombinerInput(GasStack gas, FluidStack fluid)
{
this.gas = gas;
this.fluid = fluid;
}
/**
* If this is a valid
* @return
*/
public boolean isValid()
{
return gas != null && fluid != null;
}
/**
* Whether or not the defined input contains the same chemicals and at least the required amount of the defined chemicals as this input.
* @param input - input to check
* @return if the input meets this input's requirements
*/
public boolean meetsInput(ChemicalCombinerInput input)
{
return meets(input);
}
/**
* Draws the needed amount of gas from each tank.
* @param gasTank - left tank to draw from
* @param fluidTank - right tank to draw from
*/
public void draw(GasTank gasTank, FluidTank fluidTank)
{
if(meets(new ChemicalCombinerInput(gasTank.getGas(), fluidTank.getFluid())))
{
gasTank.draw(gas.amount, true);
fluidTank.drain(fluid.amount, true);
}
}
/**
* Actual implementation of meetsInput(), performs the checks.
* @param input - input to check
* @return if the input meets this input's requirements
*/
private boolean meets(ChemicalCombinerInput input)
{
if(input == null || !input.isValid())
{
return false;
}
if(input.gas.getGas() != gas.getGas() || input.fluid.getFluid() != fluid.getFluid())
{
return false;
}
return input.gas.amount >= gas.amount && input.fluid.amount >= fluid.amount;
}
}
+10 -3
View File
@@ -150,15 +150,22 @@ public class Gas
}
/**
* Registers a new fluid out of this Gas.
* Registers a new fluid out of this Gas or gets one from the FluidRegistry.
* @return this Gas object
*/
public Gas registerFluid()
{
if(fluid == null)
{
fluid = new Fluid(getName()).setGaseous(true);
FluidRegistry.registerFluid(fluid);
if(FluidRegistry.getFluid(getName()) == null)
{
fluid = new Fluid(getName()).setGaseous(true);
FluidRegistry.registerFluid(fluid);
}
else
{
fluid = FluidRegistry.getFluid(getName());
}
}
return this;
+25 -31
View File
@@ -1,10 +1,8 @@
package mekanism.client;
import java.io.File;
import java.util.HashMap;
import mekanism.client.gui.GuiChemicalCombiner;
import mekanism.client.gui.GuiChemicalInfuser;
import mekanism.client.gui.GuiChemicalInjectionChamber;
import mekanism.client.gui.GuiChemicalOxidizer;
@@ -81,7 +79,6 @@ import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityChemicalCombiner;
import mekanism.common.tileentity.TileEntityChemicalInfuser;
import mekanism.common.tileentity.TileEntityChemicalInjectionChamber;
import mekanism.common.tileentity.TileEntityChemicalOxidizer;
@@ -276,7 +273,6 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter", new RenderTeleporter());
ClientRegistry.registerTileEntity(TileEntityChemicalOxidizer.class, "ChemicalOxidizer", new RenderChemicalOxidizer());
ClientRegistry.registerTileEntity(TileEntityChemicalInfuser.class, "ChemicalInfuser", new RenderChemicalInfuser());
GameRegistry.registerTileEntity(TileEntityChemicalCombiner.class, "ChemicalCombiner");
ClientRegistry.registerTileEntity(TileEntityChemicalInjectionChamber.class, "ChemicalInjectionChamber", new RenderConfigurableMachine());
}
@@ -327,50 +323,50 @@ public class ClientProxy extends CommonProxy
case 1:
return new GuiCredits();
case 2:
return new GuiDigitalMiner(player.inventory, (TileEntityDigitalMiner) tileEntity);
return new GuiDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity);
case 3:
return new GuiEnrichmentChamber(player.inventory, (TileEntityElectricMachine) tileEntity);
return new GuiEnrichmentChamber(player.inventory, (TileEntityElectricMachine)tileEntity);
case 4:
return new GuiOsmiumCompressor(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity);
return new GuiOsmiumCompressor(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
case 5:
return new GuiCombiner(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity);
return new GuiCombiner(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
case 6:
return new GuiCrusher(player.inventory, (TileEntityElectricMachine) tileEntity);
return new GuiCrusher(player.inventory, (TileEntityElectricMachine)tileEntity);
case 7:
return new GuiRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator) tileEntity);
return new GuiRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity);
case 8:
return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube) tileEntity);
return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity);
case 9:
return new GuiConfiguration(player, (IInvConfiguration) tileEntity);
return new GuiConfiguration(player, (IInvConfiguration)tileEntity);
case 10:
return new GuiGasTank(player.inventory, (TileEntityGasTank) tileEntity);
return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity);
case 11:
return new GuiFactory(player.inventory, (TileEntityFactory) tileEntity);
return new GuiFactory(player.inventory, (TileEntityFactory)tileEntity);
case 12:
return new GuiMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser) tileEntity);
return new GuiMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity);
case 13:
return new GuiTeleporter(player.inventory, (TileEntityTeleporter) tileEntity);
return new GuiTeleporter(player.inventory, (TileEntityTeleporter)tileEntity);
case 14:
ItemStack itemStack = player.getCurrentEquippedItem();
if (itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter)
if(itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter)
{
return new GuiPortableTeleporter(player, itemStack);
}
case 15:
return new GuiPurificationChamber(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity);
return new GuiPurificationChamber(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
case 16:
return new GuiEnergizedSmelter(player.inventory, (TileEntityElectricMachine) tileEntity);
return new GuiEnergizedSmelter(player.inventory, (TileEntityElectricMachine)tileEntity);
case 17:
return new GuiElectricPump(player.inventory, (TileEntityElectricPump) tileEntity);
return new GuiElectricPump(player.inventory, (TileEntityElectricPump)tileEntity);
case 18:
return new GuiDynamicTank(player.inventory, (TileEntityDynamicTank) tileEntity);
return new GuiDynamicTank(player.inventory, (TileEntityDynamicTank)tileEntity);
case 19:
return new GuiPasswordEnter((TileEntityElectricChest) tileEntity);
return new GuiPasswordEnter((TileEntityElectricChest)tileEntity);
case 20:
return new GuiPasswordModify((TileEntityElectricChest) tileEntity);
return new GuiPasswordModify((TileEntityElectricChest)tileEntity);
case 21:
EntityRobit robit = (EntityRobit) world.getEntityByID(x);
EntityRobit robit = (EntityRobit)world.getEntityByID(x);
if(robit != null)
{
@@ -379,14 +375,14 @@ public class ClientProxy extends CommonProxy
case 22:
return new GuiRobitCrafting(player.inventory, world, x);
case 23:
EntityRobit robit1 = (EntityRobit) world.getEntityByID(x);
EntityRobit robit1 = (EntityRobit)world.getEntityByID(x);
if(robit1 != null)
{
return new GuiRobitInventory(player.inventory, robit1);
}
case 24:
EntityRobit robit2 = (EntityRobit) world.getEntityByID(x);
EntityRobit robit2 = (EntityRobit)world.getEntityByID(x);
if(robit2 != null)
{
@@ -395,13 +391,11 @@ public class ClientProxy extends CommonProxy
case 25:
return new GuiRobitRepair(player.inventory, world, x);
case 29:
return new GuiChemicalOxidizer(player.inventory, (TileEntityChemicalOxidizer) tileEntity);
return new GuiChemicalOxidizer(player.inventory, (TileEntityChemicalOxidizer)tileEntity);
case 30:
return new GuiChemicalInfuser(player.inventory, (TileEntityChemicalInfuser) tileEntity);
return new GuiChemicalInfuser(player.inventory, (TileEntityChemicalInfuser)tileEntity);
case 31:
return new GuiChemicalInjectionChamber(player.inventory, (TileEntityAdvancedElectricMachine) tileEntity);
case 32:
return new GuiChemicalCombiner(player.inventory, (TileEntityChemicalCombiner) tileEntity);
return new GuiChemicalInjectionChamber(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
}
return null;
@@ -1,186 +0,0 @@
package mekanism.client.gui;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.gas.GasStack;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.inventory.container.ContainerChemicalCombiner;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.tileentity.TileEntityChemicalCombiner;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiChemicalCombiner extends GuiMekanism
{
public TileEntityChemicalCombiner tileEntity;
public GuiChemicalCombiner(InventoryPlayer inventory, TileEntityChemicalCombiner tentity)
{
super(tentity, new ContainerChemicalCombiner(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCombiner.png")));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString(MekanismUtils.localize("gui.chemicalCombiner.short"), 5, 5, 0x404040);
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040);
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
}
if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluidAmount() : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
}
if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5 && yAxis <= 63)
{
drawCreativeTabHoveringText(tileEntity.centerTank.getGas() != null ? tileEntity.centerTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.centerTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCombiner.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int xAxis = mouseX - guiWidth;
int yAxis = mouseY - guiHeight;
int displayInt;
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4);
if(tileEntity.isActive)
{
drawTexturedModalRect(guiWidth + 47, guiHeight + 39, 176, 71, 28, 8);
drawTexturedModalRect(guiWidth + 101, guiHeight + 39, 176, 63, 28, 8);
}
if(tileEntity.getScaledGasLevel(58) > 0)
{
displayGauge(26, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank.getGas());
}
if(tileEntity.getScaledFluidLevel(58) > 0)
{
displayGauge(134, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null);
}
if(tileEntity.getScaledOutputLevel(58) > 0)
{
displayGauge(80, 5, tileEntity.getScaledOutputLevel(58), null, tileEntity.centerTank.getGas());
}
}
@Override
protected void mouseClicked(int x, int y, int button)
{
super.mouseClicked(x, y, button);
if(button == 0)
{
int xAxis = (x - (width - xSize) / 2);
int yAxis = (y - (height - ySize) / 2);
if(xAxis > 44 && xAxis < 62 && yAxis > 13 && yAxis < 21)
{
ArrayList data = new ArrayList();
data.add(0);
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
else if(xAxis > 114 && xAxis < 132 && yAxis > 13 && yAxis < 21)
{
ArrayList data = new ArrayList();
data.add(1);
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
}
}
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas)
{
if(fluid == null && gas == null)
{
return;
}
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
int start = 0;
while(true)
{
int renderRemaining = 0;
if(scale > 16)
{
renderRemaining = 16;
scale -= 16;
}
else {
renderRemaining = scale;
scale = 0;
}
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
if(fluid != null)
{
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
}
else if(gas != null)
{
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining));
}
start+=16;
if(renderRemaining == 0 || scale == 0)
{
break;
}
}
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCombiner.png"));
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 4, 16, 59);
}
}
@@ -114,6 +114,10 @@ public class GuiFactory extends GuiMekanism
{
recipeFuelY += 10;
}
else if(tileEntity.recipeType == RecipeType.INJECTING.ordinal())
{
recipeFuelY += 15;
}
displayInt = tileEntity.getScaledSecondaryEnergy(160);
drawTexturedModalRect(guiWidth + 8, guiHeight + 78, 0, recipeFuelY, displayInt, 5);
@@ -9,6 +9,7 @@ import mekanism.common.ISpecialBounds;
import mekanism.common.ObfuscatedNames;
import mekanism.common.util.MekanismUtils;
import net.minecraft.block.Block;
import net.minecraft.block.BlockFluid;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.OpenGlHelper;
@@ -66,6 +67,7 @@ public class MekanismRenderer
GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:LiquidHydrogen"));
GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:LiquidOxygen"));
GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:WaterVapor"));
GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurDioxide"));
GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:LiquidSulfurTrioxide"));
GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:LiquidSulfuricAcid"));
-4
View File
@@ -58,7 +58,6 @@ public class CommonProxy
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter");
GameRegistry.registerTileEntity(TileEntityChemicalOxidizer.class, "ChemicalOxidizer");
GameRegistry.registerTileEntity(TileEntityChemicalInfuser.class, "ChemicalInfuser");
GameRegistry.registerTileEntity(TileEntityChemicalCombiner.class, "ChemicalCombiner");
GameRegistry.registerTileEntity(TileEntityChemicalInjectionChamber.class, "ChemicalInjectionChamber");
}
@@ -158,7 +157,6 @@ public class CommonProxy
Mekanism.rotaryCondensentratorUsage = Mekanism.configuration.get("usage", "RotaryCondensentratorUsage", 50D).getDouble(50D);
Mekanism.oxidationChamberUsage = Mekanism.configuration.get("usage", "OxidationChamberUsage", 100D).getDouble(100D);
Mekanism.chemicalInfuserUsage = Mekanism.configuration.get("usage", "ChemicalInfuserUsage", 100D).getDouble(100D);
Mekanism.chemicalCombinerUsage = Mekanism.configuration.get("usage", "ChemicalCombinerUsage", 100D).getDouble(100D);
Mekanism.chemicalInjectionChamberUsage = Mekanism.configuration.get("usage", "ChemicalInjectionChamberUsage", 200D).getDouble(200D);
Mekanism.configuration.save();
}
@@ -297,8 +295,6 @@ public class CommonProxy
return new ContainerChemicalInfuser(player.inventory, (TileEntityChemicalInfuser)tileEntity);
case 31:
return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity);
case 32:
return new ContainerChemicalCombiner(player.inventory, (TileEntityChemicalCombiner)tileEntity);
}
return null;
+20 -7
View File
@@ -10,7 +10,6 @@ import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import mekanism.api.ChemicalCombinerInput;
import mekanism.api.ChemicalInput;
import mekanism.api.Coord4D;
import mekanism.api.EnumColor;
@@ -97,6 +96,7 @@ import mekanism.common.network.PacketWalkieTalkieState;
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
import mekanism.common.tileentity.TileEntityBoundingBlock;
import mekanism.common.tileentity.TileEntityElectricBlock;
import mekanism.common.tileentity.TileEntityEnergizedSmelter;
import mekanism.common.transporter.TransporterManager;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
@@ -111,8 +111,6 @@ import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import rebelkeithy.mods.metallurgy.api.IOreInfo;
@@ -293,7 +291,6 @@ public class Mekanism
public static double rotaryCondensentratorUsage;
public static double oxidationChamberUsage;
public static double chemicalInfuserUsage;
public static double chemicalCombinerUsage;
public static double chemicalInjectionChamberUsage;
/**
@@ -634,10 +631,8 @@ public class Mekanism
//Chemical Infuser Recipes
RecipeHandler.addChemicalInfuserRecipe(new ChemicalInput(new GasStack(GasRegistry.getGas("oxygen"), 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2)), new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2));
RecipeHandler.addChemicalInfuserRecipe(new ChemicalInput(new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), new GasStack(GasRegistry.getGas("water"), 1)), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1));
//Chemical Combiner Recipes
RecipeHandler.addChemicalCombinerRecipe(new ChemicalCombinerInput(new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), new FluidStack(FluidRegistry.getFluid("water"), 1)), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1));
//Infuse objects
InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10));
InfuseRegistry.registerInfuseObject(new ItemStack(Item.coal, 1, 1), new InfuseObject(InfuseRegistry.get("CARBON"), 20));
@@ -923,6 +918,23 @@ public class Mekanism
voiceManager.start();
}
//Load cached furnace recipes
TileEntityEnergizedSmelter.furnaceRecipes.clear();
for(Map.Entry<List<Integer>, ItemStack> entry : FurnaceRecipes.smelting().getMetaSmeltingList().entrySet())
{
TileEntityEnergizedSmelter.furnaceRecipes.put(new ItemStack(entry.getKey().get(0), 1, entry.getKey().get(1)), entry.getValue());
}
for(Object obj : FurnaceRecipes.smelting().getSmeltingList().entrySet())
{
if(obj instanceof Map.Entry)
{
Map.Entry<Integer, ItemStack> entry = (Map.Entry<Integer, ItemStack>)obj;
TileEntityEnergizedSmelter.furnaceRecipes.put(new ItemStack(entry.getKey(), 1, 0), entry.getValue());
}
}
event.registerServerCommand(new CommandMekanism());
}
@@ -964,6 +976,7 @@ public class Mekanism
GasRegistry.register(new Gas("hydrogen")).registerFluid();
GasRegistry.register(new Gas("oxygen")).registerFluid();
GasRegistry.register(new Gas("water")).registerFluid();
GasRegistry.register(new Gas("sulfurDioxideGas")).registerFluid();
GasRegistry.register(new Gas("sulfurTrioxideGas")).registerFluid();
GasRegistry.register(new Gas("sulfuricAcid")).registerFluid();
+24 -46
View File
@@ -3,7 +3,6 @@ package mekanism.common;
import java.util.HashMap;
import java.util.Map;
import mekanism.api.ChemicalCombinerInput;
import mekanism.api.ChemicalInput;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
@@ -11,7 +10,6 @@ import mekanism.api.infuse.InfusionInput;
import mekanism.api.infuse.InfusionOutput;
import mekanism.common.util.StackUtils;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidTank;
/**
* Class used to handle machine recipes. This is used for both adding recipes and checking outputs.
@@ -95,15 +93,6 @@ public final class RecipeHandler
Recipe.CHEMICAL_INFUSER.put(input, output);
}
/**
* Add a Chemical Combiner recipe
* @param input - input ChemicalCombinerInput
*/
public static void addChemicalCombinerRecipe(ChemicalCombinerInput input, GasStack output)
{
Recipe.CHEMICAL_COMBINER.put(input, output);
}
/**
* Add a Chemical Oxidizer recipe.
* @param input - input ItemStack
@@ -191,40 +180,6 @@ public final class RecipeHandler
return null;
}
/**
* Gets the GasStack of the ChemicalCombinerInput in the parameters.
* @param gasTank - GasTank containing the gas to use
* @param fluidTank - FluidTank containing the fluid to use
* @param doRemove - actually drain the tanks
* @return output - GasStack returned
*/
public static GasStack getChemicalCombinerOutput(GasTank gasTank, FluidTank fluidTank, boolean doRemove)
{
ChemicalCombinerInput input = new ChemicalCombinerInput(gasTank.getGas(), fluidTank.getFluid());
if(input.isValid())
{
HashMap<ChemicalCombinerInput, GasStack> recipes = Recipe.CHEMICAL_COMBINER.get();
for(Map.Entry<ChemicalCombinerInput, GasStack> entry : recipes.entrySet())
{
ChemicalCombinerInput key = (ChemicalCombinerInput)entry.getKey();
if(key.meetsInput(input))
{
if(doRemove)
{
key.draw(gasTank, fluidTank);
}
return entry.getValue().copy();
}
}
}
return null;
}
/**
* Gets the InfusionOutput of the ItemStack in the parameters.
@@ -287,6 +242,30 @@ public final class RecipeHandler
return null;
}
/**
* Gets the output ItemStack of the ItemStack in the parameters.
* @param itemstack - input ItemStack
* @param recipes - Map of recipes
* @return whether the item can be used in a recipe
*/
public static boolean isInRecipe(ItemStack itemstack, Map<ItemStack, ItemStack> recipes)
{
if(itemstack != null)
{
for(Map.Entry entry : recipes.entrySet())
{
ItemStack stack = (ItemStack)entry.getKey();
if(StackUtils.equalsWildcard(stack, itemstack))
{
return true;
}
}
}
return false;
}
public static enum Recipe
{
ENRICHMENT_CHAMBER(new HashMap<ItemStack, ItemStack>()),
@@ -296,7 +275,6 @@ public final class RecipeHandler
PURIFICATION_CHAMBER(new HashMap<ItemStack, ItemStack>()),
METALLURGIC_INFUSER(new HashMap<InfusionInput, InfusionOutput>()),
CHEMICAL_INFUSER(new HashMap<ChemicalInput, GasStack>()),
CHEMICAL_COMBINER(new HashMap<ChemicalCombinerInput, GasStack>()),
CHEMICAL_OXIDIZER(new HashMap<ItemStack, GasStack>()),
CHEMICAL_INJECTION_CHAMBER(new HashMap<ItemStack, ItemStack>());
+23 -22
View File
@@ -1072,27 +1072,26 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
public static enum MachineType
{
ENRICHMENT_CHAMBER(Mekanism.machineBlockID, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, false),
OSMIUM_COMPRESSOR(Mekanism.machineBlockID, 1, "OsmiumCompressor", 4, Mekanism.osmiumCompressorUsage*400, TileEntityOsmiumCompressor.class, false),
COMBINER(Mekanism.machineBlockID, 2, "Combiner", 5, Mekanism.combinerUsage*400, TileEntityCombiner.class, false),
CRUSHER(Mekanism.machineBlockID, 3, "Crusher", 6, Mekanism.crusherUsage*400, TileEntityCrusher.class, false),
DIGITAL_MINER(Mekanism.machineBlockID, 4, "DigitalMiner", 2, 100000, TileEntityDigitalMiner.class, true),
BASIC_FACTORY(Mekanism.machineBlockID, 5, "BasicFactory", 11, Mekanism.factoryUsage*3*400, TileEntityFactory.class, false),
ADVANCED_FACTORY(Mekanism.machineBlockID, 6, "AdvancedFactory", 11, Mekanism.factoryUsage*5*400, TileEntityAdvancedFactory.class, false),
ELITE_FACTORY(Mekanism.machineBlockID, 7, "EliteFactory", 11, Mekanism.factoryUsage*7*400, TileEntityEliteFactory.class, false),
METALLURGIC_INFUSER(Mekanism.machineBlockID, 8, "MetallurgicInfuser", 12, Mekanism.metallurgicInfuserUsage*400, TileEntityMetallurgicInfuser.class, true),
PURIFICATION_CHAMBER(Mekanism.machineBlockID, 9, "PurificationChamber", 15, Mekanism.purificationChamberUsage*400, TileEntityPurificationChamber.class, false),
ENERGIZED_SMELTER(Mekanism.machineBlockID, 10, "EnergizedSmelter", 16, Mekanism.energizedSmelterUsage*400, TileEntityEnergizedSmelter.class, false),
TELEPORTER(Mekanism.machineBlockID, 11, "Teleporter", 13, 5000000, TileEntityTeleporter.class, false),
ELECTRIC_PUMP(Mekanism.machineBlockID, 12, "ElectricPump", 17, 10000, TileEntityElectricPump.class, true),
ELECTRIC_CHEST(Mekanism.machineBlockID, 13, "ElectricChest", -1, 12000, TileEntityElectricChest.class, true),
CHARGEPAD(Mekanism.machineBlockID, 14, "Chargepad", -1, 10000, TileEntityChargepad.class, true),
LOGISTICAL_SORTER(Mekanism.machineBlockID, 15, "LogisticalSorter", -1, 0, TileEntityLogisticalSorter.class, true),
ROTARY_CONDENSENTRATOR(Mekanism.machineBlock2ID, 0, "RotaryCondensentrator", 7, 20000, TileEntityRotaryCondensentrator.class, true),
CHEMICAL_OXIDIZER(Mekanism.machineBlock2ID, 1, "ChemicalOxidizer", 29, 20000, TileEntityChemicalOxidizer.class, true),
CHEMICAL_INFUSER(Mekanism.machineBlock2ID, 2, "ChemicalInfuser", 30, 20000, TileEntityChemicalInfuser.class, true),
CHEMICAL_COMBINER(Mekanism.machineBlock2ID, 3, "ChemicalCombiner", 32, 20000, TileEntityChemicalCombiner.class, false),
CHEMICAL_INJECTION_CHAMBER(Mekanism.machineBlock2ID, 4, "ChemicalInjectionChamber", 31, Mekanism.chemicalInjectionChamberUsage*400, TileEntityChemicalInjectionChamber.class, false);
ENRICHMENT_CHAMBER(Mekanism.machineBlockID, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, false, true),
OSMIUM_COMPRESSOR(Mekanism.machineBlockID, 1, "OsmiumCompressor", 4, Mekanism.osmiumCompressorUsage*400, TileEntityOsmiumCompressor.class, false, true),
COMBINER(Mekanism.machineBlockID, 2, "Combiner", 5, Mekanism.combinerUsage*400, TileEntityCombiner.class, false, true),
CRUSHER(Mekanism.machineBlockID, 3, "Crusher", 6, Mekanism.crusherUsage*400, TileEntityCrusher.class, false, true),
DIGITAL_MINER(Mekanism.machineBlockID, 4, "DigitalMiner", 2, 100000, TileEntityDigitalMiner.class, true, true),
BASIC_FACTORY(Mekanism.machineBlockID, 5, "BasicFactory", 11, Mekanism.factoryUsage*3*400, TileEntityFactory.class, false, true),
ADVANCED_FACTORY(Mekanism.machineBlockID, 6, "AdvancedFactory", 11, Mekanism.factoryUsage*5*400, TileEntityAdvancedFactory.class, false, true),
ELITE_FACTORY(Mekanism.machineBlockID, 7, "EliteFactory", 11, Mekanism.factoryUsage*7*400, TileEntityEliteFactory.class, false, true),
METALLURGIC_INFUSER(Mekanism.machineBlockID, 8, "MetallurgicInfuser", 12, Mekanism.metallurgicInfuserUsage*400, TileEntityMetallurgicInfuser.class, true, true),
PURIFICATION_CHAMBER(Mekanism.machineBlockID, 9, "PurificationChamber", 15, Mekanism.purificationChamberUsage*400, TileEntityPurificationChamber.class, false, true),
ENERGIZED_SMELTER(Mekanism.machineBlockID, 10, "EnergizedSmelter", 16, Mekanism.energizedSmelterUsage*400, TileEntityEnergizedSmelter.class, false, true),
TELEPORTER(Mekanism.machineBlockID, 11, "Teleporter", 13, 5000000, TileEntityTeleporter.class, false, false),
ELECTRIC_PUMP(Mekanism.machineBlockID, 12, "ElectricPump", 17, 10000, TileEntityElectricPump.class, true, false),
ELECTRIC_CHEST(Mekanism.machineBlockID, 13, "ElectricChest", -1, 12000, TileEntityElectricChest.class, true, false),
CHARGEPAD(Mekanism.machineBlockID, 14, "Chargepad", -1, 10000, TileEntityChargepad.class, true, false),
LOGISTICAL_SORTER(Mekanism.machineBlockID, 15, "LogisticalSorter", -1, 0, TileEntityLogisticalSorter.class, true, false),
ROTARY_CONDENSENTRATOR(Mekanism.machineBlock2ID, 0, "RotaryCondensentrator", 7, 20000, TileEntityRotaryCondensentrator.class, true, false),
CHEMICAL_OXIDIZER(Mekanism.machineBlock2ID, 1, "ChemicalOxidizer", 29, 20000, TileEntityChemicalOxidizer.class, true, false),
CHEMICAL_INFUSER(Mekanism.machineBlock2ID, 2, "ChemicalInfuser", 30, 20000, TileEntityChemicalInfuser.class, true, false),
CHEMICAL_INJECTION_CHAMBER(Mekanism.machineBlock2ID, 3, "ChemicalInjectionChamber", 31, Mekanism.chemicalInjectionChamberUsage*400, TileEntityChemicalInjectionChamber.class, false, true);
public int typeId;
public int meta;
@@ -1101,8 +1100,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
public double baseEnergy;
public Class<? extends TileEntity> tileEntityClass;
public boolean hasModel;
public boolean supportsUpgrades;
private MachineType(int id, int i, String s, int j, double k, Class<? extends TileEntity> tileClass, boolean model)
private MachineType(int id, int i, String s, int j, double k, Class<? extends TileEntity> tileClass, boolean model, boolean upgrades)
{
typeId = id;
meta = i;
@@ -1111,6 +1111,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
baseEnergy = k;
tileEntityClass = tileClass;
hasModel = model;
supportsUpgrades = upgrades;
}
public static MachineType get(int id, int meta)
@@ -1,147 +0,0 @@
package mekanism.common.inventory.container;
import mekanism.api.gas.IGasItem;
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
import mekanism.common.inventory.slot.SlotStorageTank;
import mekanism.common.item.ItemMachineUpgrade;
import mekanism.common.tileentity.TileEntityChemicalCombiner;
import mekanism.common.tileentity.TileEntityChemicalInfuser;
import mekanism.common.util.ChargeUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerChemicalCombiner extends Container
{
private TileEntityChemicalCombiner tileEntity;
public ContainerChemicalCombiner(InventoryPlayer inventory, TileEntityChemicalCombiner tentity)
{
tileEntity = tentity;
addSlotToContainer(new SlotStorageTank(tentity, null, true, 0, 5, 56));
addSlotToContainer(new SlotStorageTank(tentity, null, true, 1, 155, 56));
addSlotToContainer(new Slot(tentity, 2, 80, 65));
addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5));
int slotX;
for(slotX = 0; slotX < 3; slotX++)
{
for(int slotY = 0; slotY < 9; slotY++)
{
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18));
}
}
for(slotX = 0; slotX < 9; ++slotX)
{
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
}
tileEntity.open(inventory.player);
tileEntity.openChest();
}
@Override
public void onContainerClosed(EntityPlayer entityplayer)
{
super.onContainerClosed(entityplayer);
tileEntity.close(entityplayer);
tileEntity.closeChest();
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotID)
{
ItemStack stack = null;
Slot currentSlot = (Slot)inventorySlots.get(slotID);
if(currentSlot != null && currentSlot.getHasStack())
{
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
if(ChargeUtils.canBeDischarged(slotStack))
{
if(slotID != 3)
{
if(!mergeItemStack(slotStack, 3, 4, false))
{
return null;
}
}
else if(slotID == 3)
{
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
{
return null;
}
}
}
else if(slotStack.getItem() instanceof IGasItem)
{
if(slotID != 0 && slotID != 1 && slotID != 2)
{
if(!mergeItemStack(slotStack, 0, 3, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true))
{
return null;
}
}
}
else {
if(slotID >= 4 && slotID <= 30)
{
if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false))
{
return null;
}
}
else if(slotID > 30)
{
if(!mergeItemStack(slotStack, 4, 30, false))
{
return null;
}
}
else {
if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true))
{
return null;
}
}
}
if(slotStack.stackSize == 0)
{
currentSlot.putStack((ItemStack)null);
}
else {
currentSlot.onSlotChanged();
}
if(slotStack.stackSize == stack.stackSize)
{
return null;
}
currentSlot.onPickupFromSlot(player, slotStack);
}
return stack;
}
}
@@ -503,11 +503,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
{
MachineType type = MachineType.get((ItemStack)data[0]);
if(type != MachineType.TELEPORTER && type != MachineType.ELECTRIC_PUMP && type != MachineType.ELECTRIC_CHEST && type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER &&
type != MachineType.ROTARY_CONDENSENTRATOR && type != MachineType.CHEMICAL_OXIDIZER && type != MachineType.CHEMICAL_INFUSER && type != MachineType.CHEMICAL_COMBINER)
{
return true;
}
return type.supportsUpgrades;
}
return false;
@@ -1,507 +0,0 @@
package mekanism.common.tileentity;
import java.util.ArrayList;
import mekanism.api.Coord4D;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasRegistry;
import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.*;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity;
import mekanism.common.util.ChargeUtils;
import mekanism.common.util.InventoryUtils;
import mekanism.common.util.MekanismUtils;
import net.minecraft.entity.player.EntityPlayer;
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;
import net.minecraftforge.fluids.*;
public class TileEntityChemicalCombiner extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IFluidHandler
{
public GasTank gasTank = new GasTank(MAX);
public FluidTank fluidTank = new FluidTank(MAX);
public GasTank centerTank = new GasTank(MAX);
public static final int MAX = 10000;
public int updateDelay;
public int gasOutput = 16;
public boolean isActive;
public boolean clientActive;
public double prevEnergy;
public final double ENERGY_USAGE = Mekanism.chemicalCombinerUsage;
/** This machine's current RedstoneControl type. */
public RedstoneControl controlType = RedstoneControl.DISABLED;
public TileEntityChemicalCombiner()
{
super("ChemicalCombiner", MachineType.CHEMICAL_COMBINER.baseEnergy);
inventory = new ItemStack[4];
}
@Override
public void onUpdate()
{
if(worldObj.isRemote)
{
if(updateDelay > 0)
{
updateDelay--;
if(updateDelay == 0 && clientActive != isActive)
{
isActive = clientActive;
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
}
}
if(!worldObj.isRemote)
{
if(updateDelay > 0)
{
updateDelay--;
if(updateDelay == 0 && clientActive != isActive)
{
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())));
}
}
ChargeUtils.discharge(3, this);
if(inventory[0] != null && (gasTank.getGas() == null || gasTank.getStored() < gasTank.getMaxGas()))
{
gasTank.receive(GasTransmission.removeGas(inventory[0], null, gasTank.getNeeded()), true);
}
if(inventory[1] != null && (fluidTank.getFluid() == null || fluidTank.getFluidAmount() < fluidTank.getCapacity()))
{
if(inventory[1].getItem() instanceof IFluidContainerItem)
{
fluidTank.fill(((IFluidContainerItem) inventory[1].getItem()).drain(inventory[1], fluidTank.getCapacity()-fluidTank.getFluidAmount(), true), true);
}
else if(FluidContainerRegistry.isFilledContainer(inventory[1]) && FluidContainerRegistry.getFluidForFilledItem(inventory[1]).equals(fluidTank.getFluid()))
{
fluidTank.fill(FluidContainerRegistry.getFluidForFilledItem(inventory[1]), true);
inventory[1] = inventory[1].getItem().getContainerItemStack(inventory[1]);
}
}
if(inventory[2] != null && centerTank.getGas() != null)
{
centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true);
}
if(canOperate() && getEnergy() >= ENERGY_USAGE && MekanismUtils.canFunction(this))
{
setActive(true);
GasStack stack = RecipeHandler.getChemicalCombinerOutput(gasTank, fluidTank, true);
centerTank.receive(stack, true);
setEnergy(getEnergy() - ENERGY_USAGE);
}
else {
if(prevEnergy >= getEnergy())
{
setActive(false);
}
}
if(centerTank.getGas() != null)
{
GasStack toSend = new GasStack(centerTank.getGas().getGas(), Math.min(centerTank.getStored(), gasOutput));
centerTank.draw(GasTransmission.emitGasToNetwork(toSend, this, ForgeDirection.getOrientation(facing)), true);
TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj);
if(tileEntity instanceof IGasHandler)
{
if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), centerTank.getGas().getGas()))
{
centerTank.draw(((IGasHandler)tileEntity).receiveGas(ForgeDirection.getOrientation(facing).getOpposite(), toSend), true);
}
}
}
prevEnergy = getEnergy();
}
}
public boolean canOperate()
{
if(gasTank.getGas() == null || fluidTank.getFluid() == null || centerTank.getNeeded() == 0)
{
return false;
}
GasStack out = RecipeHandler.getChemicalCombinerOutput(gasTank, fluidTank, false);
if(out == null)
{
return false;
}
if(centerTank.getNeeded() < out.amount)
{
return false;
}
return true;
}
@Override
public void handlePacketData(ByteArrayDataInput dataStream)
{
if(!worldObj.isRemote)
{
int type = dataStream.readInt();
if(type == 0)
{
gasTank.setGas(null);
}
else if(type == 1)
{
fluidTank.setFluid(null);
}
for(EntityPlayer player : playersUsing)
{
PacketHandler.sendPacket(Transmission.SINGLE_CLIENT, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())), player);
}
return;
}
super.handlePacketData(dataStream);
isActive = dataStream.readBoolean();
controlType = RedstoneControl.values()[dataStream.readInt()];
if(dataStream.readBoolean())
{
gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
}
else {
gasTank.setGas(null);
}
if(dataStream.readBoolean())
{
fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt()));
}
else {
fluidTank.setFluid(null);
}
if(dataStream.readBoolean())
{
centerTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt()));
}
else {
centerTank.setGas(null);
}
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
}
@Override
public ArrayList getNetworkedData(ArrayList data)
{
super.getNetworkedData(data);
data.add(isActive);
data.add(controlType.ordinal());
if(gasTank.getGas() != null)
{
data.add(true);
data.add(gasTank.getGas().getGas().getID());
data.add(gasTank.getStored());
}
else {
data.add(false);
}
if(fluidTank.getFluid() != null)
{
data.add(true);
data.add(fluidTank.getFluid().getFluid().getID());
data.add(fluidTank.getFluidAmount());
}
else {
data.add(false);
}
if(centerTank.getGas() != null)
{
data.add(true);
data.add(centerTank.getGas().getGas().getID());
data.add(centerTank.getStored());
}
else {
data.add(false);
}
return data;
}
@Override
public void readFromNBT(NBTTagCompound nbtTags)
{
super.readFromNBT(nbtTags);
isActive = nbtTags.getBoolean("isActive");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
gasTank.read(nbtTags.getCompoundTag("gasTank"));
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
centerTank.read(nbtTags.getCompoundTag("centerTank"));
}
@Override
public void writeToNBT(NBTTagCompound nbtTags)
{
super.writeToNBT(nbtTags);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("controlType", controlType.ordinal());
nbtTags.setCompoundTag("gasTank", gasTank.write(new NBTTagCompound()));
nbtTags.setCompoundTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound()));
nbtTags.setCompoundTag("centerTank", centerTank.write(new NBTTagCompound()));
}
@Override
public boolean canSetFacing(int i)
{
return i != 0 && i != 1;
}
public GasTank getGasTank(ForgeDirection side)
{
if(side == MekanismUtils.getLeft(facing))
{
return gasTank;
}
else if(side == ForgeDirection.getOrientation(facing))
{
return centerTank;
}
return null;
}
public FluidTank getFluidTank(ForgeDirection side)
{
if(side == MekanismUtils.getRight(facing))
{
return fluidTank;
}
return null;
}
public int getScaledGasLevel(int i)
{
return gasTank != null ? gasTank.getStored()*i / MAX : 0;
}
public int getScaledFluidLevel(int i)
{
return fluidTank != null ? fluidTank.getFluidAmount()*i / MAX : 0;
}
public int getScaledOutputLevel(int i)
{
return centerTank != null ? centerTank.getStored()*i / MAX : 0;
}
@Override
public void setActive(boolean active)
{
isActive = active;
if(clientActive != active && updateDelay == 0)
{
PacketHandler.sendPacket(Transmission.ALL_CLIENTS, new PacketTileEntity().setParams(Coord4D.get(this), getNetworkedData(new ArrayList())));
updateDelay = 10;
clientActive = active;
}
}
@Override
public boolean getActive()
{
return isActive;
}
@Override
public boolean renderUpdate()
{
return false;
}
@Override
public boolean lightUpdate()
{
return true;
}
@Override
public boolean canTubeConnect(ForgeDirection side)
{
return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing) || side == ForgeDirection.getOrientation(facing);
}
@Override
public boolean canReceiveGas(ForgeDirection side, Gas type)
{
return getGasTank(side) != null && getGasTank(side) != centerTank ? getGasTank(side).canReceive(type) : false;
}
@Override
public RedstoneControl getControlType()
{
return controlType;
}
@Override
public void setControlType(RedstoneControl type)
{
controlType = type;
MekanismUtils.saveChunk(this);
}
@Override
public int receiveGas(ForgeDirection side, GasStack stack)
{
if(canReceiveGas(side, stack != null ? stack.getGas() : null))
{
return getGasTank(side).receive(stack, true);
}
return 0;
}
@Override
public GasStack drawGas(ForgeDirection side, int amount)
{
if(canDrawGas(side, null))
{
return getGasTank(side).draw(amount, true);
}
return null;
}
@Override
public boolean canDrawGas(ForgeDirection side, Gas type)
{
return getGasTank(side) != null && getGasTank(side) == centerTank ? getGasTank(side).canDraw(type) : false;
}
@Override
public boolean isItemValidForSlot(int slotID, ItemStack itemstack)
{
if(slotID == 3)
{
return ChargeUtils.canBeDischarged(itemstack);
}
return false;
}
@Override
public boolean canExtractItem(int slotID, ItemStack itemstack, int side)
{
if(slotID == 0)
{
return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canReceiveGas(itemstack, null);
}
if(slotID == 1)
{
return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null);
}
return false;
}
@Override
public int[] getAccessibleSlotsFromSide(int side)
{
if(side == MekanismUtils.getLeft(facing).ordinal())
{
return new int[] {0};
}
else if(side == facing)
{
return new int[] {1};
}
else if(side == MekanismUtils.getRight(facing).ordinal())
{
return new int[] {2};
}
else if(side == 0 || side == 1)
{
return new int[3];
}
return InventoryUtils.EMPTY;
}
@Override
public int fill(ForgeDirection side, FluidStack resource, boolean doFill) {
return getFluidTank(side) == null ? 0 : getFluidTank(side).fill(resource, doFill);
}
@Override
public FluidStack drain(ForgeDirection side, FluidStack resource, boolean doDrain) {
return getFluidTank(side) == null && getFluidTank(side).getFluid().isFluidEqual(resource) ? null : getFluidTank(side).drain(resource.amount, doDrain);
}
@Override
public FluidStack drain(ForgeDirection side, int maxDrain, boolean doDrain) {
return getFluidTank(side) == null ? null : getFluidTank(side).drain(maxDrain, doDrain);
}
@Override
public boolean canFill(ForgeDirection side, Fluid fluid) {
return getFluidTank(side) != null && (getFluidTank(side).getFluid() == null || getFluidTank(side).getFluid().getFluid() == fluid);
}
@Override
public boolean canDrain(ForgeDirection side, Fluid fluid) {
return getFluidTank(side) != null && getFluidTank(side).getFluid().getFluid() == fluid;
}
@Override
public FluidTankInfo[] getTankInfo(ForgeDirection side) {
if(getFluidTank(side) == null)
{
return new FluidTankInfo[0];
}
return new FluidTankInfo[] {new FluidTankInfo(getFluidTank(side))};
}
}
@@ -22,7 +22,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
*
* @param soundPath - location of the sound effect
* @param name - full name of this machine
* @param path - GUI texture path of this machine
* @param location - GUI texture path of this machine
* @param perTick - energy used per tick.
* @param ticksRequired - ticks required to operate -- or smelt an item.
* @param maxEnergy - maximum energy this machine can hold.
@@ -100,7 +100,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
}
else if(slotID == 0)
{
return RecipeHandler.getOutput(itemstack, false, getRecipes()) != null;
return RecipeHandler.isInRecipe(itemstack, getRecipes());
}
else if(slotID == 1)
{
@@ -12,6 +12,8 @@ import net.minecraft.util.ResourceLocation;
public class TileEntityEnergizedSmelter extends TileEntityElectricMachine
{
public static Map<ItemStack, ItemStack> furnaceRecipes = new HashMap<ItemStack, ItemStack>();
public TileEntityEnergizedSmelter()
{
super("Smelter.ogg", "EnergizedSmelter", new ResourceLocation("mekanism", "gui/GuiEnergizedSmelter.png"), Mekanism.energizedSmelterUsage, 200, MachineType.ENERGIZED_SMELTER.baseEnergy);
@@ -20,22 +22,6 @@ public class TileEntityEnergizedSmelter extends TileEntityElectricMachine
@Override
public Map getRecipes()
{
HashMap<ItemStack, ItemStack> map = new HashMap<ItemStack, ItemStack>();
for(Map.Entry<List<Integer>, ItemStack> entry : FurnaceRecipes.smelting().getMetaSmeltingList().entrySet())
{
map.put(new ItemStack(entry.getKey().get(0), 1, entry.getKey().get(1)), entry.getValue());
}
for(Object obj : FurnaceRecipes.smelting().getSmeltingList().entrySet())
{
if(obj instanceof Map.Entry)
{
Map.Entry<Integer, ItemStack> entry = (Map.Entry<Integer, ItemStack>)obj;
map.put(new ItemStack(entry.getKey(), 1, 0), entry.getValue());
}
}
return map;
return furnaceRecipes;
}
}
@@ -140,6 +140,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
if(!worldObj.isRemote)
{
if(ticker == 1)
{
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType().blockID);
}
if(updateDelay > 0)
{
updateDelay--;
@@ -598,7 +602,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
super.readFromNBT(nbtTags);
clientActive = isActive = nbtTags.getBoolean("isActive");
recipeType = Math.min(5, nbtTags.getInteger("recipeType"));
recipeType = nbtTags.getInteger("recipeType");
recipeTicks = nbtTags.getInteger("recipeTicks");
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
secondaryEnergyStored = nbtTags.getInteger("secondaryEnergyStored");
@@ -887,7 +891,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
@Override
public int receiveGas(ForgeDirection side, GasStack stack)
{
if(stack.getGas() == GasRegistry.getGas("oxygen"))
if(recipeType == RecipeType.PURIFYING.ordinal() && stack.getGas() == GasRegistry.getGas("oxygen") ||
recipeType == RecipeType.INJECTING.ordinal() && stack.getGas() == GasRegistry.getGas("sulfuricAcid"))
{
int toUse = Math.min(getMaxSecondaryEnergy()-secondaryEnergyStored, stack.amount);
secondaryEnergyStored += toUse;
@@ -900,13 +905,14 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
@Override
public boolean canReceiveGas(ForgeDirection side, Gas type)
{
return type == GasRegistry.getGas("oxygen");
return recipeType == RecipeType.PURIFYING.ordinal() && type == GasRegistry.getGas("oxygen") ||
recipeType == RecipeType.INJECTING.ordinal() && type == GasRegistry.getGas("sulfuricAcid");
}
@Override
public boolean canTubeConnect(ForgeDirection side)
{
return recipeType == RecipeType.PURIFYING.ordinal();
return recipeType == RecipeType.PURIFYING.ordinal() || recipeType == RecipeType.INJECTING.ordinal();
}
@Override
@@ -508,7 +508,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
@Override
public boolean canFill(ForgeDirection from, Fluid fluid)
{
return mode == 1 && from == MekanismUtils.getRight(facing) && (fluidTank.getFluid() == null && isValidFluid(new FluidStack(fluid, 1)) || fluidTank.getFluid().getFluid() == fluid);
return mode == 1 && from == MekanismUtils.getRight(facing) && (fluidTank.getFluid() == null ? isValidFluid(new FluidStack(fluid, 1)) : fluidTank.getFluid().getFluid() == fluid);
}
@Override
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

@@ -3,6 +3,7 @@ tile.Transmitter.PressurizedTube.name=Pressurised Tube
tile.MachineBlock2.ChemicalOxidizer=Chemical Oxidiser
item.MultipartTransmitter.PressurizedTube.name=Pressurised Tube
item.sulfurDust.name=Sulphur Dust
gas.water=Water Vapour
gas.sulfurDioxideGas=Sulphur Dioxide
gas.sulfurTrioxideGas=Sulphur Trioxide
gas.sulfuricAcid=Sulphuric Acid
@@ -152,6 +152,7 @@ item.tinIngot.name=Tin Ingot
//Gasses
gas.hydrogen=Hydrogen
gas.oxygen=Oxygen
gas.water=Water Vapor
gas.sulfurDioxideGas=Sulfur Dioxide
gas.sulfurTrioxideGas=Sulfur Trioxide
gas.sulfuricAcid=Sulfuric Acid
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}