Get most of the contact process stuff working with WIP textures and such. .langs will need updating again for new things (Chemical Combiner is a provisional name though, for the time being.)

This commit is contained in:
Ben Spiers 2014-01-01 03:03:23 +00:00
parent 571ad3944f
commit 544d96f3bc
19 changed files with 1021 additions and 72 deletions

View file

@ -0,0 +1,84 @@
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;
}
}

View file

@ -4,36 +4,7 @@ package mekanism.client;
import java.io.File;
import java.util.HashMap;
import mekanism.client.gui.GuiChemicalInfuser;
import mekanism.client.gui.GuiChemicalInjectionChamber;
import mekanism.client.gui.GuiCombiner;
import mekanism.client.gui.GuiConfiguration;
import mekanism.client.gui.GuiCredits;
import mekanism.client.gui.GuiCrusher;
import mekanism.client.gui.GuiDictionary;
import mekanism.client.gui.GuiDigitalMiner;
import mekanism.client.gui.GuiDynamicTank;
import mekanism.client.gui.GuiElectricChest;
import mekanism.client.gui.GuiElectricPump;
import mekanism.client.gui.GuiEnergizedSmelter;
import mekanism.client.gui.GuiEnergyCube;
import mekanism.client.gui.GuiEnrichmentChamber;
import mekanism.client.gui.GuiFactory;
import mekanism.client.gui.GuiGasTank;
import mekanism.client.gui.GuiMetallurgicInfuser;
import mekanism.client.gui.GuiOsmiumCompressor;
import mekanism.client.gui.GuiChemicalOxidizer;
import mekanism.client.gui.GuiPasswordEnter;
import mekanism.client.gui.GuiPasswordModify;
import mekanism.client.gui.GuiPortableTeleporter;
import mekanism.client.gui.GuiPurificationChamber;
import mekanism.client.gui.GuiRobitCrafting;
import mekanism.client.gui.GuiRobitInventory;
import mekanism.client.gui.GuiRobitMain;
import mekanism.client.gui.GuiRobitRepair;
import mekanism.client.gui.GuiRobitSmelting;
import mekanism.client.gui.GuiRotaryCondensentrator;
import mekanism.client.gui.GuiTeleporter;
import mekanism.client.gui.*;
import mekanism.client.render.MekanismRenderer;
import mekanism.client.render.RenderPartTransmitter;
import mekanism.client.render.RenderTickHandler;
@ -75,39 +46,7 @@ import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.inventory.InventoryElectricChest;
import mekanism.common.item.ItemPortableTeleporter;
import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
import mekanism.common.tileentity.TileEntityAdvancedFactory;
import mekanism.common.tileentity.TileEntityBin;
import mekanism.common.tileentity.TileEntityChargepad;
import mekanism.common.tileentity.TileEntityChemicalInfuser;
import mekanism.common.tileentity.TileEntityChemicalInjectionChamber;
import mekanism.common.tileentity.TileEntityCombiner;
import mekanism.common.tileentity.TileEntityCrusher;
import mekanism.common.tileentity.TileEntityDigitalMiner;
import mekanism.common.tileentity.TileEntityDiversionTransporter;
import mekanism.common.tileentity.TileEntityDynamicTank;
import mekanism.common.tileentity.TileEntityDynamicValve;
import mekanism.common.tileentity.TileEntityElectricChest;
import mekanism.common.tileentity.TileEntityElectricMachine;
import mekanism.common.tileentity.TileEntityElectricPump;
import mekanism.common.tileentity.TileEntityEliteFactory;
import mekanism.common.tileentity.TileEntityEnergizedSmelter;
import mekanism.common.tileentity.TileEntityEnergyCube;
import mekanism.common.tileentity.TileEntityEnrichmentChamber;
import mekanism.common.tileentity.TileEntityFactory;
import mekanism.common.tileentity.TileEntityGasTank;
import mekanism.common.tileentity.TileEntityLogisticalSorter;
import mekanism.common.tileentity.TileEntityLogisticalTransporter;
import mekanism.common.tileentity.TileEntityMechanicalPipe;
import mekanism.common.tileentity.TileEntityMetallurgicInfuser;
import mekanism.common.tileentity.TileEntityObsidianTNT;
import mekanism.common.tileentity.TileEntityOsmiumCompressor;
import mekanism.common.tileentity.TileEntityChemicalOxidizer;
import mekanism.common.tileentity.TileEntityPressurizedTube;
import mekanism.common.tileentity.TileEntityPurificationChamber;
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
import mekanism.common.tileentity.TileEntityTeleporter;
import mekanism.common.tileentity.TileEntityUniversalCable;
import mekanism.common.tileentity.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
@ -273,6 +212,7 @@ public class ClientProxy extends CommonProxy
ClientRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter", new RenderTeleporter());
ClientRegistry.registerTileEntity(TileEntityChemicalOxidizer.class, "ChemicalOxidizer", new RenderChemicalOxidizer());
GameRegistry.registerTileEntity(TileEntityChemicalInfuser.class, "ChemicalInfuser");
GameRegistry.registerTileEntity(TileEntityChemicalCombiner.class, "ChemicalCombiner");
ClientRegistry.registerTileEntity(TileEntityChemicalInjectionChamber.class, "ChemicalInjectionChamber", new RenderConfigurableMachine());
}
@ -396,6 +336,8 @@ public class ClientProxy extends CommonProxy
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 null;

View file

@ -0,0 +1,186 @@
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);
}
}

View file

@ -58,12 +58,13 @@ 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");
}
/**
* Registers a client-side sound, assigned to a TileEntity.
* @param tileEntity - TileEntity who is registering the sound
* @param obj - TileEntity who is registering the sound
*/
public void registerSound(Object obj) {}
@ -157,6 +158,7 @@ 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();
}
@ -295,6 +297,8 @@ 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;

View file

@ -10,6 +10,7 @@ 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;
@ -110,6 +111,8 @@ 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;
@ -290,6 +293,7 @@ public class Mekanism
public static double rotaryCondensentratorUsage;
public static double oxidationChamberUsage;
public static double chemicalInfuserUsage;
public static double chemicalCombinerUsage;
public static double chemicalInjectionChamberUsage;
/**
@ -619,6 +623,9 @@ 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));
//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));

View file

@ -3,6 +3,7 @@ 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;
@ -10,6 +11,7 @@ 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.
@ -93,6 +95,15 @@ 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
@ -149,7 +160,9 @@ public final class RecipeHandler
/**
* Gets the GasStack of the ChemicalInput in the parameters.
* @param input - input ChemicalInput
* @param leftTank - first GasTank
* @param rightTank - second GasTank
* @param doRemove - actually remove the gases
* @return output GasStack
*/
public static GasStack getChemicalInfuserOutput(GasTank leftTank, GasTank rightTank, boolean doRemove)
@ -179,6 +192,40 @@ 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.
* @param itemstack - input ItemStack
@ -249,6 +296,7 @@ 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>());

View file

@ -138,6 +138,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
icons[3][0] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOff");
icons[3][1] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOn");
icons[3][2] = register.registerIcon("mekanism:SteelCasing");
icons[4][0] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOff");
icons[4][1] = register.registerIcon("mekanism:ChemicalInjectionChamberFrontOn");
icons[4][2] = register.registerIcon("mekanism:SteelCasing");
}
}
@ -413,6 +416,16 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
return icons[3][2];
}
}
else if(meta == 4)
{
if(side == 3)
{
return icons[4][0];
}
else {
return icons[4][2];
}
}
}
return null;
@ -536,7 +549,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
}
else if(blockID == Mekanism.machineBlock2ID)
{
if(metadata == 2 || metadata == 3)
if(metadata == 2 || metadata == 3 || metadata == 4)
{
if(side == tileEntity.facing)
{
@ -1078,6 +1091,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
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, false),
CHEMICAL_COMBINER(Mekanism.machineBlock2ID, 4, "ChemicalCombiner", 32, 20000, TileEntityChemicalCombiner.class, false),
CHEMICAL_INJECTION_CHAMBER(Mekanism.machineBlock2ID, 3, "ChemicalInjectionChamber", 31, Mekanism.chemicalInjectionChamberUsage*400, TileEntityChemicalInjectionChamber.class, false);
public int typeId;

View file

@ -0,0 +1,147 @@
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;
}
}

View file

@ -504,7 +504,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.ROTARY_CONDENSENTRATOR && type != MachineType.CHEMICAL_OXIDIZER && type != MachineType.CHEMICAL_INFUSER && type != MachineType.CHEMICAL_COMBINER)
{
return true;
}

View file

@ -0,0 +1,507 @@
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))};
}
}

View file

@ -314,12 +314,12 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
public int getScaledRightGasLevel(int i)
{
return leftTank != null ? rightTank.getStored()*i / MAX_GAS : 0;
return rightTank != null ? rightTank.getStored()*i / MAX_GAS : 0;
}
public int getScaledCenterGasLevel(int i)
{
return leftTank != null ? centerTank.getStored()*i / MAX_GAS : 0;
return centerTank != null ? centerTank.getStored()*i / MAX_GAS : 0;
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -4,8 +4,9 @@ tile.MachineBlock2.ChemicalOxidizer=Chemical Oxidiser
item.MultipartTransmitter.PressurizedTube.name=Pressurised Tube
item.sulfurDust.name=Sulphur Dust
gas.sulfurDioxideGas=Sulphur Dioxide
gas.sulfuricAcid=Aerosolised Sulphuric Acid
gas.sulfurTrioxideGas=Sulphur Trioxide
gas.sulfuricAcid=Sulphuric Acid
fluid.sulfurDioxideGas=Liquid Sulphur Dioxide
fluid.sulfuricAcid=Sulphuric Acid
tooltip.EnergizedSmelter=A simple machine that serves as a Mekanism-based !nfurnace that runs off of energy.
fluid.sulfurTrioxideGas=Liquid Sulphur Trioxide
fluid.sulfuricAcid=Liquid Sulphuric Acid
tooltip.Chargepad=A universal chargepad that can charge any energised item !nfrom any mod.

View file

@ -68,6 +68,7 @@ tile.MachineBlock.DigitalMiner.name=Digital Miner
tile.MachineBlock2.RotaryCondensentrator.name=Rotary Condensentrator
tile.MachineBlock2.ChemicalOxidizer.name=Chemical Oxidizer
tile.MachineBlock2.ChemicalInfuser.name=Chemical Infuser
tile.MachineBlock2.ChemicalCombiner.name=Chemical Combiner
tile.MachineBlock2.ChemicalInjectionChamber.name=Chemical Injection Chamber
//Ore Block
@ -152,12 +153,14 @@ item.tinIngot.name=Tin Ingot
gas.hydrogen=Hydrogen
gas.oxygen=Oxygen
gas.sulfurDioxideGas=Sulfur Dioxide
gas.sulfurTrioxideGas=Sulfur Trioxide
gas.sulfuricAcid=Sulfuric Acid
//Fluids
fluid.hydrogen=Liquid Hydrogen
fluid.oxygen=Liquid Oxygen
fluid.sulfurDioxideGas=Liquid Sulfur Dioxide
fluid.sulfurTrioxideGas=Liquid Sulfur Trioxide
fluid.sulfuricAcid=Liquid Sulfuric Acid
//Gui text
@ -196,6 +199,7 @@ gui.off=Off
gui.filters=Filters
gui.chemicalInfuser.short=C. Infuser
gui.chemicalCombiner.short=C. Combiner
gui.dictionary.noKey=No key.
gui.dictionary.key=Key

View file

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B