Infusing Factories. They're finally here
This commit is contained in:
parent
88cfee2ab2
commit
5aaea55900
12 changed files with 333 additions and 54 deletions
|
@ -1,7 +1,9 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.util.ListUtils;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo;
|
||||
import mekanism.client.gui.element.GuiEnergyInfo.IInfoHandler;
|
||||
|
@ -12,14 +14,21 @@ import mekanism.client.gui.element.GuiSortingTab;
|
|||
import mekanism.client.gui.element.GuiTransporterConfigTab;
|
||||
import mekanism.client.gui.element.GuiUpgradeTab;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.inventory.container.ContainerFactory;
|
||||
import mekanism.common.item.ItemGaugeDropper;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -69,7 +78,14 @@ public class GuiFactory extends GuiMekanism
|
|||
|
||||
if(xAxis >= 8 && xAxis <= 168 && yAxis >= 78 && yAxis <= 83)
|
||||
{
|
||||
drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis);
|
||||
if(tileEntity.recipeType.usesFuel())
|
||||
{
|
||||
drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis);
|
||||
}
|
||||
else if(tileEntity.recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
drawCreativeTabHoveringText(tileEntity.infuseStored.type != null ? tileEntity.infuseStored.type.getLocalizedName() + ": " + tileEntity.infuseStored.amount : LangUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
}
|
||||
}
|
||||
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
|
@ -105,9 +121,19 @@ public class GuiFactory extends GuiMekanism
|
|||
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt);
|
||||
}
|
||||
|
||||
if(tileEntity.getScaledGasLevel(160) > 0)
|
||||
if(tileEntity.recipeType.usesFuel())
|
||||
{
|
||||
displayGauge(8, 78, tileEntity.getScaledGasLevel(160), 5, tileEntity.gasTank.getGas().getGas().getIcon());
|
||||
if(tileEntity.getScaledGasLevel(160) > 0)
|
||||
{
|
||||
displayGauge(8, 78, tileEntity.getScaledGasLevel(160), 5, tileEntity.gasTank.getGas().getGas().getIcon());
|
||||
}
|
||||
}
|
||||
else if(tileEntity.recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
if(tileEntity.getScaledInfuseLevel(160) > 0)
|
||||
{
|
||||
displayGauge(8, 78, tileEntity.getScaledInfuseLevel(160), 5, tileEntity.infuseStored.type.icon);
|
||||
}
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
@ -126,4 +152,30 @@ public class GuiFactory extends GuiMekanism
|
|||
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos, icon, sizeX, sizeY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int x, int y, int button)
|
||||
{
|
||||
super.mouseClicked(x, y, button);
|
||||
|
||||
if(button == 0 || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
|
||||
{
|
||||
int xAxis = (x - (width - xSize) / 2);
|
||||
int yAxis = (y - (height - ySize) / 2);
|
||||
|
||||
if(xAxis > 8 && xAxis < 168 && yAxis > 78 && yAxis < 83)
|
||||
{
|
||||
ItemStack stack = mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if(stack != null && stack.getItem() instanceof ItemGaugeDropper)
|
||||
{
|
||||
ArrayList data = new ArrayList();
|
||||
data.add(1);
|
||||
|
||||
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,8 +134,9 @@ public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler
|
|||
float f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F;
|
||||
if(ticksPassed < 20) f = 0.0F;
|
||||
|
||||
int display = (int)(52F*f);
|
||||
changeTexture(MekanismRenderer.getBlocksTexture());
|
||||
drawTexturedRectFromIcon(2, 2, type.icon, 4, (int)(52F*f));
|
||||
drawTexturedRectFromIcon(2, 2+52-display, type.icon, 4, display);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,14 +5,17 @@ import java.util.Map;
|
|||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.inputs.ItemStackInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.recipe.machines.MachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -49,7 +52,8 @@ public interface IFactory
|
|||
COMPRESSING("Compressing", "compressor", MachineType.OSMIUM_COMPRESSOR.getStack(), true, false, Recipe.OSMIUM_COMPRESSOR),
|
||||
COMBINING("Combining", "combiner", MachineType.COMBINER.getStack(), true, false, Recipe.COMBINER),
|
||||
PURIFYING("Purifying", "purifier", MachineType.PURIFICATION_CHAMBER.getStack(), true, true, Recipe.PURIFICATION_CHAMBER),
|
||||
INJECTING("Injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, true, Recipe.CHEMICAL_INJECTION_CHAMBER);
|
||||
INJECTING("Injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, true, Recipe.CHEMICAL_INJECTION_CHAMBER),
|
||||
INFUSING("Infusing", "metalinfuser", MachineType.METALLURGIC_INFUSER.getStack(), false, false, Recipe.METALLURGIC_INFUSER);
|
||||
|
||||
private String name;
|
||||
private ResourceLocation sound;
|
||||
|
@ -78,13 +82,27 @@ public interface IFactory
|
|||
{
|
||||
return getRecipe(new AdvancedMachineInput(input, gas));
|
||||
}
|
||||
|
||||
public MetallurgicInfuserRecipe getRecipe(InfusionInput input)
|
||||
{
|
||||
return RecipeHandler.getMetallurgicInfuserRecipe(input);
|
||||
}
|
||||
|
||||
public MetallurgicInfuserRecipe getRecipe(ItemStack input, InfuseStorage storage)
|
||||
{
|
||||
return getRecipe(new InfusionInput(storage, input));
|
||||
}
|
||||
|
||||
public MachineRecipe getAnyRecipe(ItemStack slotStack, Gas gasType)
|
||||
public MachineRecipe getAnyRecipe(ItemStack slotStack, Gas gasType, InfuseStorage infuse)
|
||||
{
|
||||
if(usesFuel())
|
||||
{
|
||||
return getRecipe(slotStack, gasType);
|
||||
}
|
||||
else if(this == INFUSING)
|
||||
{
|
||||
return getRecipe(slotStack, infuse);
|
||||
}
|
||||
|
||||
return getRecipe(slotStack);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package mekanism.common.inventory.container;
|
||||
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.common.Tier;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
|
@ -8,7 +9,6 @@ import mekanism.common.inventory.slot.SlotOutput;
|
|||
import mekanism.common.item.ItemBlockMachine;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.util.ChargeUtils;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
@ -143,7 +143,7 @@ public class ContainerFactory extends Container
|
|||
return null;
|
||||
}
|
||||
}
|
||||
else if(tileEntity.recipeType.getAnyRecipe(slotStack, tileEntity.gasTank.getGasType()) != null)
|
||||
else if(tileEntity.recipeType.getAnyRecipe(slotStack, tileEntity.gasTank.getGasType(), tileEntity.infuseStored) != null)
|
||||
{
|
||||
if(!isInputSlot(slotID))
|
||||
{
|
||||
|
@ -192,6 +192,25 @@ public class ContainerFactory extends Container
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(tileEntity.recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
if(InfuseRegistry.getObject(slotStack) != null && (tileEntity.infuseStored.type == null || tileEntity.infuseStored.type == InfuseRegistry.getObject(slotStack).type))
|
||||
{
|
||||
if(slotID > tileEntity.inventory.length-1)
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 3, 4, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int slotEnd = tileEntity.inventory.length-1;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
|||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
import mekanism.common.tile.TileEntityElectricMachine;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.tile.TileEntityMetallurgicInfuser;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -102,6 +103,17 @@ public class ItemFactoryInstaller extends ItemMekanism
|
|||
stack.stackSize = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(tile instanceof TileEntityMetallurgicInfuser)
|
||||
{
|
||||
((TileEntityMetallurgicInfuser)tile).upgrade(type);
|
||||
|
||||
if(!player.capabilities.isCreativeMode)
|
||||
{
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package mekanism.common.recipe.machines;
|
|||
import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.outputs.ItemStackOutput;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class MetallurgicInfuserRecipe extends MachineRecipe<InfusionInput, ItemStackOutput, MetallurgicInfuserRecipe>
|
||||
|
@ -18,9 +17,9 @@ public class MetallurgicInfuserRecipe extends MachineRecipe<InfusionInput, ItemS
|
|||
this(input, new ItemStackOutput(output));
|
||||
}
|
||||
|
||||
public boolean canOperate(ItemStack[] inventory, InfuseStorage infuse)
|
||||
public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuse)
|
||||
{
|
||||
return getInput().use(inventory, 2, infuse, false) && getOutput().applyOutputs(inventory, 3, false);
|
||||
return getInput().use(inventory, inputIndex, infuse, false) && getOutput().applyOutputs(inventory, outputIndex, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -29,11 +28,11 @@ public class MetallurgicInfuserRecipe extends MachineRecipe<InfusionInput, ItemS
|
|||
return new MetallurgicInfuserRecipe(getInput(), getOutput());
|
||||
}
|
||||
|
||||
public void output(ItemStack[] inventory, InfuseStorage infuseStored)
|
||||
public void output(ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuseStored)
|
||||
{
|
||||
if(getInput().use(inventory, 2, infuseStored, true))
|
||||
if(getInput().use(inventory, inputIndex, infuseStored, true))
|
||||
{
|
||||
getOutput().applyOutputs(inventory, 3, true);
|
||||
getOutput().applyOutputs(inventory, outputIndex, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,22 +4,18 @@ import io.netty.buffer.ByteBuf;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
|
@ -108,7 +104,6 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
|||
|
||||
//Electric
|
||||
factory.electricityStored = electricityStored;
|
||||
factory.ic2Registered = ic2Registered;
|
||||
|
||||
//Noisy
|
||||
factory.soundURL = soundURL;
|
||||
|
@ -144,7 +139,6 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
|||
factory.upgraded = true;
|
||||
|
||||
factory.markDirty();
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(factory)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.*;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
|
@ -20,8 +26,6 @@ import mekanism.common.util.MekanismUtils;
|
|||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecipe<RECIPE>> extends TileEntityBasicMachine<ItemStackInput, ItemStackOutput, RECIPE>
|
||||
{
|
||||
/**
|
||||
|
@ -72,7 +76,6 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
|||
|
||||
//Electric
|
||||
factory.electricityStored = electricityStored;
|
||||
factory.ic2Registered = ic2Registered;
|
||||
|
||||
//Noisy
|
||||
factory.soundURL = soundURL;
|
||||
|
@ -104,7 +107,6 @@ public abstract class TileEntityElectricMachine<RECIPE extends BasicMachineRecip
|
|||
factory.upgraded = true;
|
||||
|
||||
factory.markDirty();
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(factory)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,12 +18,16 @@ import mekanism.api.gas.GasTransmission;
|
|||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.api.infuse.InfuseObject;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.api.util.StackUtils;
|
||||
import mekanism.client.HolidayManager;
|
||||
import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Tier.FactoryTier;
|
||||
import mekanism.common.Upgrade;
|
||||
|
@ -36,8 +40,12 @@ import mekanism.common.base.SoundWrapper;
|
|||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.integration.IComputerIntegration;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.recipe.RecipeHandler;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
import mekanism.common.recipe.inputs.InfusionInput;
|
||||
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
|
||||
import mekanism.common.recipe.machines.BasicMachineRecipe;
|
||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||
import mekanism.common.tile.component.TileComponentConfig;
|
||||
import mekanism.common.tile.component.TileComponentEjector;
|
||||
import mekanism.common.tile.component.TileComponentUpgrade;
|
||||
|
@ -59,6 +67,10 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
|
||||
/** An int[] used to track all current operations' progress. */
|
||||
public int[] progress;
|
||||
|
||||
public int BASE_MAX_INFUSE = 1000;
|
||||
|
||||
public int maxInfuse = BASE_MAX_INFUSE;
|
||||
|
||||
/** How many ticks it takes, by default, to run an operation. */
|
||||
public int BASE_TICKS_REQUIRED = 200;
|
||||
|
@ -94,6 +106,9 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
|
||||
/** This machine's recipe type. */
|
||||
public RecipeType recipeType = RecipeType.SMELTING;
|
||||
|
||||
/** The amount of infuse this machine has stored. */
|
||||
public InfuseStorage infuseStored = new InfuseStorage();
|
||||
|
||||
/** This machine's previous amount of energy. */
|
||||
public double prevEnergy;
|
||||
|
@ -149,6 +164,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
isActive = false;
|
||||
|
||||
gasTank = new GasTank(TileEntityAdvancedElectricMachine.MAX_GAS*tier.processes);
|
||||
maxInfuse = BASE_MAX_INFUSE*tier.processes;
|
||||
}
|
||||
|
||||
public void upgrade()
|
||||
|
@ -168,7 +184,6 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
|
||||
//Electric
|
||||
factory.electricityStored = electricityStored;
|
||||
factory.ic2Registered = ic2Registered;
|
||||
|
||||
//Noisy
|
||||
factory.soundURL = soundURL;
|
||||
|
@ -367,6 +382,12 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
setActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if(infuseStored.amount <= 0)
|
||||
{
|
||||
infuseStored.amount = 0;
|
||||
infuseStored.type = null;
|
||||
}
|
||||
|
||||
prevEnergy = getEnergy();
|
||||
}
|
||||
|
@ -463,33 +484,58 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
|
||||
public void handleSecondaryFuel()
|
||||
{
|
||||
if(inventory[4] != null && recipeType.usesFuel() && gasTank.getNeeded() > 0)
|
||||
if(inventory[4] != null)
|
||||
{
|
||||
if(inventory[4].getItem() instanceof IGasItem)
|
||||
if(recipeType.usesFuel() && gasTank.getNeeded() > 0)
|
||||
{
|
||||
GasStack gas = ((IGasItem)inventory[4].getItem()).getGas(inventory[4]);
|
||||
|
||||
if(gas != null && recipeType.isValidGas(gas.getGas()))
|
||||
if(inventory[4].getItem() instanceof IGasItem)
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[4], gasTank.getGasType(), gasTank.getNeeded());
|
||||
gasTank.receive(removed, true);
|
||||
GasStack gas = ((IGasItem)inventory[4].getItem()).getGas(inventory[4]);
|
||||
|
||||
if(gas != null && recipeType.isValidGas(gas.getGas()))
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[4], gasTank.getGasType(), gasTank.getNeeded());
|
||||
gasTank.receive(removed, true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GasStack stack = recipeType.getItemGas(inventory[4]);
|
||||
int gasNeeded = gasTank.getNeeded();
|
||||
|
||||
if(stack != null && stack.amount <= gasNeeded)
|
||||
{
|
||||
gasTank.receive(stack, true);
|
||||
|
||||
inventory[4].stackSize--;
|
||||
|
||||
if(inventory[4].stackSize == 0)
|
||||
|
||||
GasStack stack = recipeType.getItemGas(inventory[4]);
|
||||
int gasNeeded = gasTank.getNeeded();
|
||||
|
||||
if(stack != null && stack.amount <= gasNeeded)
|
||||
{
|
||||
inventory[4] = null;
|
||||
gasTank.receive(stack, true);
|
||||
|
||||
inventory[4].stackSize--;
|
||||
|
||||
if(inventory[4].stackSize == 0)
|
||||
{
|
||||
inventory[4] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
if(InfuseRegistry.getObject(inventory[4]) != null)
|
||||
{
|
||||
InfuseObject infuse = InfuseRegistry.getObject(inventory[4]);
|
||||
|
||||
if(infuseStored.type == null || infuseStored.type == infuse.type)
|
||||
{
|
||||
if(infuseStored.amount + infuse.stored <= maxInfuse)
|
||||
{
|
||||
infuseStored.amount += infuse.stored;
|
||||
infuseStored.type = infuse.type;
|
||||
inventory[4].stackSize--;
|
||||
|
||||
if(inventory[4].stackSize <= 0)
|
||||
{
|
||||
inventory[4] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -534,7 +580,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
}
|
||||
else if(slotID >= 5 && slotID <= 7)
|
||||
{
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType()) != null;
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null;
|
||||
}
|
||||
}
|
||||
else if(tier == FactoryTier.ADVANCED)
|
||||
|
@ -545,7 +591,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
}
|
||||
else if(slotID >= 5 && slotID <= 9)
|
||||
{
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType()) != null;
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null;
|
||||
}
|
||||
}
|
||||
else if(tier == FactoryTier.ELITE)
|
||||
|
@ -556,7 +602,7 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
}
|
||||
else if(slotID >= 5 && slotID <= 11)
|
||||
{
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType()) != null;
|
||||
return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,7 +616,31 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
}
|
||||
else if(slotID == 4)
|
||||
{
|
||||
return recipeType.getItemGas(itemstack) != null;
|
||||
if(recipeType.usesFuel())
|
||||
{
|
||||
return recipeType.getItemGas(itemstack) != null;
|
||||
}
|
||||
else if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
if(infuseStored.type != null)
|
||||
{
|
||||
if(RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuseStored, itemstack)) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet())
|
||||
{
|
||||
InfusionInput input = (InfusionInput)obj;
|
||||
|
||||
if(input.inputStack.isItemEqual(itemstack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -580,6 +650,11 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
{
|
||||
return progress[process]*i / ticksRequired;
|
||||
}
|
||||
|
||||
public int getScaledInfuseLevel(int i)
|
||||
{
|
||||
return infuseStored.amount * i / maxInfuse;
|
||||
}
|
||||
|
||||
public int getScaledGasLevel(int i)
|
||||
{
|
||||
|
@ -609,6 +684,19 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
|
||||
return recipe.canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick);
|
||||
}
|
||||
|
||||
if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]);
|
||||
MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(input);
|
||||
|
||||
if(recipe == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return recipe.canOperate(inventory, inputSlot, outputSlot, infuseStored);
|
||||
}
|
||||
|
||||
BasicMachineRecipe<?> recipe = recipeType.getRecipe(inventory[inputSlot]);
|
||||
|
||||
|
@ -633,6 +721,13 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
|
||||
recipe.operate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick);
|
||||
}
|
||||
else if(recipeType == RecipeType.INFUSING)
|
||||
{
|
||||
InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]);
|
||||
MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(input);
|
||||
|
||||
recipe.output(inventory, inputSlot, outputSlot, infuseStored);
|
||||
}
|
||||
else {
|
||||
BasicMachineRecipe<?> recipe = recipeType.getRecipe(inventory[inputSlot]);
|
||||
|
||||
|
@ -654,6 +749,12 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
{
|
||||
sorting = !sorting;
|
||||
}
|
||||
else if(type == 1)
|
||||
{
|
||||
gasTank.setGas(null);
|
||||
infuseStored.amount = 0;
|
||||
infuseStored.type = null;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -674,6 +775,8 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
sorting = dataStream.readBoolean();
|
||||
upgraded = dataStream.readBoolean();
|
||||
infuseStored.amount = dataStream.readInt();
|
||||
infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream));
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -721,6 +824,8 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
recipeTicks = nbtTags.getInteger("recipeTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
sorting = nbtTags.getBoolean("sorting");
|
||||
infuseStored.amount = nbtTags.getInteger("infuseStored");
|
||||
infuseStored.type = InfuseRegistry.get(nbtTags.getString("type"));
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -740,6 +845,15 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
nbtTags.setInteger("recipeTicks", recipeTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setBoolean("sorting", sorting);
|
||||
nbtTags.setInteger("infuseStored", infuseStored.amount);
|
||||
|
||||
if(infuseStored.type != null)
|
||||
{
|
||||
nbtTags.setString("type", infuseStored.type.name);
|
||||
}
|
||||
else {
|
||||
nbtTags.setString("type", "null");
|
||||
}
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -760,6 +874,16 @@ public class TileEntityFactory extends TileEntityNoisyElectricBlock implements I
|
|||
data.add(controlType.ordinal());
|
||||
data.add(sorting);
|
||||
data.add(upgraded);
|
||||
data.add(infuseStored.amount);
|
||||
|
||||
if(infuseStored.type != null)
|
||||
{
|
||||
data.add(infuseStored.type.name);
|
||||
}
|
||||
else {
|
||||
data.add("null");
|
||||
}
|
||||
|
||||
data.add(progress);
|
||||
|
||||
if(gasTank.getGas() != null)
|
||||
|
|
|
@ -15,11 +15,13 @@ import mekanism.api.infuse.InfuseRegistry;
|
|||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.InfuseStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IEjector;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
|
@ -193,6 +195,61 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
|||
}
|
||||
}
|
||||
|
||||
public void upgrade(RecipeType type)
|
||||
{
|
||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
|
||||
worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3);
|
||||
|
||||
TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(xCoord, yCoord, zCoord);
|
||||
|
||||
//Basic
|
||||
factory.facing = facing;
|
||||
factory.clientFacing = clientFacing;
|
||||
factory.ticker = ticker;
|
||||
factory.redstone = redstone;
|
||||
factory.redstoneLastTick = redstoneLastTick;
|
||||
factory.doAutoSync = doAutoSync;
|
||||
|
||||
//Electric
|
||||
factory.electricityStored = electricityStored;
|
||||
|
||||
//Noisy
|
||||
factory.soundURL = soundURL;
|
||||
|
||||
//Machine
|
||||
factory.progress[0] = operatingTicks;
|
||||
factory.clientActive = clientActive;
|
||||
factory.isActive = isActive;
|
||||
factory.updateDelay = updateDelay;
|
||||
factory.controlType = controlType;
|
||||
factory.prevEnergy = prevEnergy;
|
||||
factory.upgradeComponent.readFrom(upgradeComponent);
|
||||
factory.upgradeComponent.setUpgradeSlot(0);
|
||||
factory.ejectorComponent.readFrom(ejectorComponent);
|
||||
factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(4));
|
||||
factory.recipeType = type;
|
||||
factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades());
|
||||
|
||||
//Infuser
|
||||
factory.infuseStored.amount = infuseStored.amount;
|
||||
factory.infuseStored.type = infuseStored.type;
|
||||
|
||||
factory.inventory[5] = inventory[2];
|
||||
factory.inventory[1] = inventory[1];
|
||||
factory.inventory[5+3] = inventory[3];
|
||||
factory.inventory[0] = inventory[0];
|
||||
factory.inventory[4] = inventory[1];
|
||||
|
||||
for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes())
|
||||
{
|
||||
factory.recalculateUpgradables(upgrade);
|
||||
}
|
||||
|
||||
factory.upgraded = true;
|
||||
|
||||
factory.markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<ForgeDirection> getConsumingSides()
|
||||
{
|
||||
|
@ -265,7 +322,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
|||
|
||||
public void operate(MetallurgicInfuserRecipe recipe)
|
||||
{
|
||||
recipe.output(inventory, infuseStored);
|
||||
recipe.output(inventory, 2, 3, infuseStored);
|
||||
|
||||
markDirty();
|
||||
ejectorComponent.outputItems();
|
||||
|
@ -273,7 +330,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock i
|
|||
|
||||
public boolean canOperate(MetallurgicInfuserRecipe recipe)
|
||||
{
|
||||
return recipe != null && recipe.canOperate(inventory, infuseStored);
|
||||
return recipe != null && recipe.canOperate(inventory, 2, 3, infuseStored);
|
||||
}
|
||||
|
||||
public int getScaledInfuseLevel(int i)
|
||||
|
|
|
@ -532,6 +532,7 @@ gui.factory.Compressing=Compressing
|
|||
gui.factory.Combining=Combining
|
||||
gui.factory.Purifying=Purifying
|
||||
gui.factory.Injecting=Injecting
|
||||
gui.factory.Infusing=Infusing
|
||||
|
||||
gui.seismicReader.short=S. Reader
|
||||
gui.seismicReader.solids=Solids
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue