Purification, Compressing, and Combining factories :)
|
@ -22,6 +22,8 @@ public class GuiFactory extends GuiMekanism
|
|||
super(new ContainerFactory(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
|
||||
ySize += 11;
|
||||
|
||||
guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.tier.guiLocation));
|
||||
guiElements.add(new GuiUpgradeManagement(this, tileEntity, tileEntity.tier.guiLocation));
|
||||
guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation));
|
||||
|
@ -95,5 +97,19 @@ public class GuiFactory extends GuiMekanism
|
|||
drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt);
|
||||
}
|
||||
}
|
||||
|
||||
int recipeFuelY = ySize;
|
||||
|
||||
if(tileEntity.recipeType == RecipeType.PURIFYING.ordinal())
|
||||
{
|
||||
recipeFuelY += 5;
|
||||
}
|
||||
else if(tileEntity.recipeType == RecipeType.COMBINING.ordinal())
|
||||
{
|
||||
recipeFuelY += 10;
|
||||
}
|
||||
|
||||
displayInt = tileEntity.getScaledSecondaryEnergy(160);
|
||||
drawTexturedModalRect(guiWidth + 8, guiHeight + 78, 0, recipeFuelY, displayInt, 5);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package mekanism.common;
|
||||
|
||||
import mekanism.common.RecipeHandler.Recipe;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.tileentity.TileEntityAdvancedElectricMachine;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
|
||||
|
@ -34,12 +36,17 @@ public interface IFactory
|
|||
|
||||
public static enum RecipeType
|
||||
{
|
||||
SMELTING("Smelting", "Smelter.ogg"),
|
||||
ENRICHING("Enriching", "Chamber.ogg"),
|
||||
CRUSHING("Crushing", "Crusher.ogg");
|
||||
SMELTING("Smelting", "Smelter.ogg", new ItemStack(Mekanism.MachineBlock, 1, MachineType.ENERGIZED_SMELTER.meta), false),
|
||||
ENRICHING("Enriching", "Chamber.ogg", new ItemStack(Mekanism.MachineBlock, 1, MachineType.ENRICHMENT_CHAMBER.meta), false),
|
||||
CRUSHING("Crushing", "Crusher.ogg", new ItemStack(Mekanism.MachineBlock, 1, MachineType.CRUSHER.meta), false),
|
||||
COMPRESSING("Compressing", "Compressor.ogg", new ItemStack(Mekanism.MachineBlock, 1, MachineType.OSMIUM_COMPRESSOR.meta), true),
|
||||
COMBINING("Combining", "Combiner.ogg", new ItemStack(Mekanism.MachineBlock, 1, MachineType.COMBINER.meta), true),
|
||||
PURIFYING("Purifying", "PurificationChamber.ogg", new ItemStack(Mekanism.MachineBlock, 1, MachineType.PURIFICATION_CHAMBER.meta), true);
|
||||
|
||||
private String name;
|
||||
private String sound;
|
||||
private ItemStack stack;
|
||||
private boolean usesFuel;
|
||||
|
||||
public ItemStack getCopiedOutput(ItemStack input, boolean stackDecrease)
|
||||
{
|
||||
|
@ -70,10 +77,66 @@ public interface IFactory
|
|||
{
|
||||
return RecipeHandler.getOutput(input, stackDecrease, Recipe.CRUSHER.get());
|
||||
}
|
||||
else if(this == COMPRESSING)
|
||||
{
|
||||
return RecipeHandler.getOutput(input, stackDecrease, Recipe.OSMIUM_COMPRESSOR.get());
|
||||
}
|
||||
else if(this == COMBINING)
|
||||
{
|
||||
return RecipeHandler.getOutput(input, stackDecrease, Recipe.COMBINER.get());
|
||||
}
|
||||
else if(this == PURIFYING)
|
||||
{
|
||||
return RecipeHandler.getOutput(input, stackDecrease, Recipe.PURIFICATION_CHAMBER.get());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getFuelTicks(ItemStack itemstack)
|
||||
{
|
||||
if(usesFuel)
|
||||
{
|
||||
MachineType type = MachineType.get(getStack().itemID, getStack().getItemDamage());
|
||||
TileEntityAdvancedElectricMachine machine = (TileEntityAdvancedElectricMachine)type.create();
|
||||
|
||||
return machine.getFuelTicks(itemstack);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getSecondaryEnergyPerTick()
|
||||
{
|
||||
if(usesFuel)
|
||||
{
|
||||
MachineType type = MachineType.get(getStack().itemID, getStack().getItemDamage());
|
||||
TileEntityAdvancedElectricMachine machine = (TileEntityAdvancedElectricMachine)type.create();
|
||||
|
||||
return machine.SECONDARY_ENERGY_PER_TICK;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getMaxSecondaryEnergy()
|
||||
{
|
||||
if(usesFuel)
|
||||
{
|
||||
MachineType type = MachineType.get(getStack().itemID, getStack().getItemDamage());
|
||||
TileEntityAdvancedElectricMachine machine = (TileEntityAdvancedElectricMachine)type.create();
|
||||
|
||||
return machine.MAX_SECONDARY_ENERGY;
|
||||
}
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
|
@ -84,10 +147,17 @@ public interface IFactory
|
|||
return sound;
|
||||
}
|
||||
|
||||
private RecipeType(String s, String s1)
|
||||
public boolean usesFuel()
|
||||
{
|
||||
return usesFuel;
|
||||
}
|
||||
|
||||
private RecipeType(String s, String s1, ItemStack is, boolean b)
|
||||
{
|
||||
name = s;
|
||||
sound = s1;
|
||||
stack = is;
|
||||
usesFuel = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -427,19 +427,11 @@ public class Mekanism
|
|||
Character.valueOf('I'), new ItemStack(BasicBlock, 1, 8), Character.valueOf('T'), TeleportationCore
|
||||
}));
|
||||
|
||||
//Factory Recipes
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.SMELTING), new Object[] {
|
||||
"CAC", "GOG", "CAC", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('O'), new ItemStack(MachineBlock, 1, 10)
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.ENRICHING), new Object[] {
|
||||
"CAC", "GOG", "CAC", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('O'), new ItemStack(MachineBlock, 1, 0)
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.CRUSHING), new Object[] {
|
||||
"CAC", "GOG", "CAC", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('O'), new ItemStack(MachineBlock, 1, 3)
|
||||
}));
|
||||
|
||||
for(RecipeType type : RecipeType.values())
|
||||
{
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, type), new Object[] {
|
||||
"CAC", "GOG", "CAC", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('O'), type.getStack()
|
||||
}));
|
||||
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(MekanismUtils.getFactory(FactoryTier.ADVANCED, type), new Object[] {
|
||||
"CAC", "DOD", "CAC", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('D'), "dustDiamond", Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.BASIC, type)
|
||||
}));
|
||||
|
|
|
@ -526,12 +526,9 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds
|
|||
|
||||
for(RecipeType type : RecipeType.values())
|
||||
{
|
||||
for(Tier.FactoryTier tier : Tier.FactoryTier.values())
|
||||
{
|
||||
ItemStack stack = new ItemStack(i, 1, 5+tier.ordinal());
|
||||
((IFactory)stack.getItem()).setRecipeType(type.ordinal(), stack);
|
||||
list.add(stack);
|
||||
}
|
||||
ItemStack stack = new ItemStack(i, 1, 7);
|
||||
((IFactory)stack.getItem()).setRecipeType(type.ordinal(), stack);
|
||||
list.add(stack);
|
||||
}
|
||||
|
||||
list.add(new ItemStack(i, 1, 8));
|
||||
|
|
|
@ -26,9 +26,10 @@ public class ContainerFactory extends Container
|
|||
tileEntity = tentity;
|
||||
|
||||
addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 1, 7, 35));
|
||||
addSlotToContainer(new SlotDischarge(tentity, 1, 7, 13));
|
||||
addSlotToContainer(new Slot(tentity, 2, 180, 75));
|
||||
addSlotToContainer(new Slot(tentity, 3, 180, 112));
|
||||
addSlotToContainer(new Slot(tentity, 4, 7, 57));
|
||||
|
||||
if(tileEntity.tier == FactoryTier.BASIC)
|
||||
{
|
||||
|
@ -36,14 +37,14 @@ public class ContainerFactory extends Container
|
|||
{
|
||||
int xAxis = 55 + (i*38);
|
||||
|
||||
addSlotToContainer(new Slot(tentity, 4+i, xAxis, 13));
|
||||
addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13));
|
||||
}
|
||||
|
||||
for(int i = 0; i < tileEntity.tier.processes; i++)
|
||||
{
|
||||
int xAxis = 55 + (i*38);
|
||||
|
||||
addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+4+i, xAxis, 57));
|
||||
addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57));
|
||||
}
|
||||
}
|
||||
else if(tileEntity.tier == FactoryTier.ADVANCED)
|
||||
|
@ -52,14 +53,14 @@ public class ContainerFactory extends Container
|
|||
{
|
||||
int xAxis = 35 + (i*26);
|
||||
|
||||
addSlotToContainer(new Slot(tentity, 4+i, xAxis, 13));
|
||||
addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13));
|
||||
}
|
||||
|
||||
for(int i = 0; i < tileEntity.tier.processes; i++)
|
||||
{
|
||||
int xAxis = 35 + (i*26);
|
||||
|
||||
addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+4+i, xAxis, 57));
|
||||
addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57));
|
||||
}
|
||||
}
|
||||
else if(tileEntity.tier == FactoryTier.ELITE)
|
||||
|
@ -68,30 +69,30 @@ public class ContainerFactory extends Container
|
|||
{
|
||||
int xAxis = 29 + (i*19);
|
||||
|
||||
addSlotToContainer(new Slot(tentity, 4+i, xAxis, 13));
|
||||
addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13));
|
||||
}
|
||||
|
||||
for(int i = 0; i < tileEntity.tier.processes; i++)
|
||||
{
|
||||
int xAxis = 29 + (i*19);
|
||||
|
||||
addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+4+i, xAxis, 57));
|
||||
addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57));
|
||||
}
|
||||
}
|
||||
|
||||
int slotX;
|
||||
|
||||
for(slotX = 0; slotX < 3; ++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));
|
||||
addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 95 + slotX * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for(slotX = 0; slotX < 9; ++slotX)
|
||||
for(slotX = 0; slotX < 9; slotX++)
|
||||
{
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142));
|
||||
addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 153));
|
||||
}
|
||||
|
||||
tileEntity.playersUsing.add(inventory.player);
|
||||
|
@ -166,7 +167,7 @@ public class ContainerFactory extends Container
|
|||
{
|
||||
if(!isInputSlot(slotID))
|
||||
{
|
||||
if(!mergeItemStack(slotStack, 4, 4+tileEntity.tier.processes, false))
|
||||
if(!mergeItemStack(slotStack, 5, 5+tileEntity.tier.processes, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -256,11 +257,11 @@ public class ContainerFactory extends Container
|
|||
public boolean isInputSlot(int slot)
|
||||
{
|
||||
if(tileEntity.tier == Tier.FactoryTier.BASIC)
|
||||
return slot >= 4 && slot <= 6;
|
||||
return slot >= 5 && slot <= 7;
|
||||
if(tileEntity.tier == Tier.FactoryTier.ADVANCED)
|
||||
return slot >= 4 && slot <= 8;
|
||||
return slot >= 5 && slot <= 9;
|
||||
if(tileEntity.tier == Tier.FactoryTier.ELITE)
|
||||
return slot >= 4 && slot <= 10;
|
||||
return slot >= 5 && slot <= 11;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -268,11 +269,11 @@ public class ContainerFactory extends Container
|
|||
public boolean isOutputSlot(int slot)
|
||||
{
|
||||
if(tileEntity.tier == Tier.FactoryTier.BASIC)
|
||||
return slot >= 7 && slot <= 9;
|
||||
return slot >= 8 && slot <= 10;
|
||||
if(tileEntity.tier == Tier.FactoryTier.ADVANCED)
|
||||
return slot >= 9 && slot <= 13;
|
||||
return slot >= 10 && slot <= 14;
|
||||
if(tileEntity.tier == Tier.FactoryTier.ELITE)
|
||||
return slot >= 11 && slot <= 17;
|
||||
return slot >= 12 && slot <= 18;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -167,9 +167,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
}
|
||||
else if(slotID == 1)
|
||||
{
|
||||
return getFuelTicks(itemstack) > 0 ||
|
||||
(this instanceof TileEntityPurificationChamber && itemstack.getItem() instanceof IStorageTank &&
|
||||
((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.OXYGEN);
|
||||
return getFuelTicks(itemstack) > 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -7,9 +7,14 @@ import java.util.ArrayList;
|
|||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.IEjector;
|
||||
import mekanism.api.IStorageTank;
|
||||
import mekanism.api.Object3D;
|
||||
import mekanism.api.SideData;
|
||||
import mekanism.api.energy.IStrictEnergyAcceptor;
|
||||
import mekanism.api.gas.EnumGas;
|
||||
import mekanism.api.gas.IGasAcceptor;
|
||||
import mekanism.api.gas.IGasStorage;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.client.sound.IHasSound;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IFactory.RecipeType;
|
||||
|
@ -36,13 +41,13 @@ import dan200.computer.api.IComputerAccess;
|
|||
import dan200.computer.api.ILuaContext;
|
||||
import dan200.computer.api.IPeripheral;
|
||||
|
||||
public class TileEntityFactory extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IStrictEnergyAcceptor, IRedstoneControl
|
||||
public class TileEntityFactory extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeTile, IHasSound, IStrictEnergyAcceptor, IRedstoneControl, IGasAcceptor, IGasStorage, ITubeConnection
|
||||
{
|
||||
/** This Factory's tier. */
|
||||
public FactoryTier tier;
|
||||
|
||||
/** This machine's side configuration. */
|
||||
public byte[] sideConfig = new byte[] {4, 3, 0, 0, 2, 1};
|
||||
public byte[] sideConfig = new byte[] {5, 4, 0, 3, 2, 1};
|
||||
|
||||
/** An arraylist of SideData for this machine. */
|
||||
public ArrayList<SideData> sideOutputs = new ArrayList<SideData>();
|
||||
|
@ -77,6 +82,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
/** This machine's previous amount of energy. */
|
||||
public double prevEnergy;
|
||||
|
||||
public int secondaryEnergyStored;
|
||||
|
||||
/** This machine's current RedstoneControl type. */
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
|
@ -90,10 +97,11 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
sideOutputs.add(new SideData(EnumColor.GREY, new int[0]));
|
||||
sideOutputs.add(new SideData(EnumColor.ORANGE, new int[] {0}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_GREEN, new int[] {1}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {4, 5, 6}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {7, 8, 9}));
|
||||
sideOutputs.add(new SideData(EnumColor.PURPLE, new int[] {4}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_RED, new int[] {5, 6, 7}));
|
||||
sideOutputs.add(new SideData(EnumColor.DARK_BLUE, new int[] {8, 9, 10}));
|
||||
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(4));
|
||||
ejectorComponent = new TileComponentEjector(this, sideOutputs.get(5));
|
||||
}
|
||||
|
||||
public TileEntityFactory(FactoryTier type, MachineType machine)
|
||||
|
@ -101,7 +109,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
super(type.name + " Factory", machine.baseEnergy);
|
||||
|
||||
tier = type;
|
||||
inventory = new ItemStack[4+type.processes*2];
|
||||
inventory = new ItemStack[5+type.processes*2];
|
||||
progress = new int[type.processes];
|
||||
isActive = false;
|
||||
}
|
||||
|
@ -141,27 +149,22 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
ChargeUtils.discharge(1, this);
|
||||
|
||||
handleSecondaryFuel();
|
||||
|
||||
if(inventory[2] != null && inventory[3] == null)
|
||||
{
|
||||
if(inventory[2].isItemEqual(new ItemStack(Mekanism.MachineBlock, 1, MachineType.ENERGIZED_SMELTER.meta)) && recipeType != 0)
|
||||
RecipeType toSet = null;
|
||||
|
||||
for(RecipeType type : RecipeType.values())
|
||||
{
|
||||
if(recipeTicks < RECIPE_TICKS_REQUIRED)
|
||||
if(inventory[2].isItemEqual(type.getStack()))
|
||||
{
|
||||
recipeTicks++;
|
||||
}
|
||||
else if(recipeTicks == RECIPE_TICKS_REQUIRED)
|
||||
{
|
||||
recipeTicks = 0;
|
||||
|
||||
inventory[2] = null;
|
||||
inventory[3] = getMachineStack();
|
||||
|
||||
recipeType = 0;
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
toSet = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(inventory[2].isItemEqual(new ItemStack(Mekanism.MachineBlock, 1, MachineType.ENRICHMENT_CHAMBER.meta)) && recipeType != 1)
|
||||
|
||||
if(toSet != null && recipeType != toSet.ordinal())
|
||||
{
|
||||
if(recipeTicks < RECIPE_TICKS_REQUIRED)
|
||||
{
|
||||
|
@ -174,25 +177,8 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
inventory[2] = null;
|
||||
inventory[3] = getMachineStack();
|
||||
|
||||
recipeType = 1;
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
}
|
||||
else if(inventory[2].isItemEqual(new ItemStack(Mekanism.MachineBlock, 1, MachineType.CRUSHER.meta)) && recipeType != 2)
|
||||
{
|
||||
if(recipeTicks < RECIPE_TICKS_REQUIRED)
|
||||
{
|
||||
recipeTicks++;
|
||||
}
|
||||
else if(recipeTicks == RECIPE_TICKS_REQUIRED)
|
||||
{
|
||||
recipeTicks = 0;
|
||||
|
||||
inventory[2] = null;
|
||||
inventory[3] = getMachineStack();
|
||||
|
||||
recipeType = 2;
|
||||
recipeType = toSet.ordinal();
|
||||
setSecondaryEnergy(0);
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
@ -207,11 +193,12 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
for(int process = 0; process < tier.processes; process++)
|
||||
{
|
||||
if(MekanismUtils.canFunction(this) && canOperate(getInputSlot(process), getOutputSlot(process)) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK))
|
||||
if(MekanismUtils.canFunction(this) && canOperate(getInputSlot(process), getOutputSlot(process)) && getEnergy() >= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK) && secondaryEnergyStored >= getSecondaryEnergyPerTick())
|
||||
{
|
||||
if((progress[process]+1) < MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
{
|
||||
progress[process]++;
|
||||
secondaryEnergyStored -= getSecondaryEnergyPerTick();
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
else if((progress[process]+1) >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
|
||||
|
@ -219,6 +206,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
operate(getInputSlot(process), getOutputSlot(process));
|
||||
|
||||
progress[process] = 0;
|
||||
secondaryEnergyStored -= getSecondaryEnergyPerTick();
|
||||
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
|
||||
}
|
||||
}
|
||||
|
@ -255,19 +243,77 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
}
|
||||
}
|
||||
|
||||
public int getSecondaryEnergyPerTick()
|
||||
{
|
||||
return RecipeType.values()[recipeType].getSecondaryEnergyPerTick();
|
||||
}
|
||||
|
||||
public int getMaxSecondaryEnergy()
|
||||
{
|
||||
return RecipeType.values()[recipeType].getMaxSecondaryEnergy()*tier.processes;
|
||||
}
|
||||
|
||||
public void handleSecondaryFuel()
|
||||
{
|
||||
if(inventory[4] != null && RecipeType.values()[recipeType].usesFuel() && secondaryEnergyStored < getMaxSecondaryEnergy())
|
||||
{
|
||||
if(recipeType == RecipeType.PURIFYING.ordinal())
|
||||
{
|
||||
if(inventory[4].getItem() instanceof IStorageTank)
|
||||
{
|
||||
if(((IStorageTank)inventory[4].getItem()).getGasType(inventory[1]) == EnumGas.OXYGEN)
|
||||
{
|
||||
IStorageTank item = (IStorageTank)inventory[4].getItem();
|
||||
|
||||
if(item.canProvideGas(inventory[4], EnumGas.OXYGEN))
|
||||
{
|
||||
int received = 0;
|
||||
int gasNeeded = getMaxSecondaryEnergy() - secondaryEnergyStored;
|
||||
|
||||
if(item.getRate() <= gasNeeded)
|
||||
{
|
||||
received = item.removeGas(inventory[4], EnumGas.OXYGEN, item.getRate());
|
||||
}
|
||||
else if(item.getRate() > gasNeeded)
|
||||
{
|
||||
received = item.removeGas(inventory[4], EnumGas.OXYGEN, gasNeeded);
|
||||
}
|
||||
|
||||
setGas(EnumGas.OXYGEN, secondaryEnergyStored + received);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int fuelTicks = RecipeType.values()[recipeType].getFuelTicks(inventory[4]);
|
||||
int energyNeeded = getMaxSecondaryEnergy() - secondaryEnergyStored;
|
||||
|
||||
if(fuelTicks > 0 && fuelTicks <= energyNeeded)
|
||||
{
|
||||
if(fuelTicks <= energyNeeded)
|
||||
{
|
||||
setSecondaryEnergy(secondaryEnergyStored + fuelTicks);
|
||||
}
|
||||
else if(fuelTicks > energyNeeded)
|
||||
{
|
||||
setSecondaryEnergy(secondaryEnergyStored + energyNeeded);
|
||||
}
|
||||
|
||||
inventory[4].stackSize--;
|
||||
|
||||
if(inventory[4].stackSize == 0)
|
||||
{
|
||||
inventory[4] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getMachineStack()
|
||||
{
|
||||
switch(recipeType)
|
||||
{
|
||||
case 0:
|
||||
return new ItemStack(Mekanism.MachineBlock, 1, MachineType.ENERGIZED_SMELTER.meta);
|
||||
case 1:
|
||||
return new ItemStack(Mekanism.MachineBlock, 1, MachineType.ENRICHMENT_CHAMBER.meta);
|
||||
case 2:
|
||||
return new ItemStack(Mekanism.MachineBlock, 1, MachineType.CRUSHER.meta);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return RecipeType.values()[recipeType].getStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -277,15 +323,15 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
return ChargeUtils.canBeOutputted(itemstack, false);
|
||||
}
|
||||
else if(tier == FactoryTier.BASIC && slotID >= 7 && slotID <= 9)
|
||||
else if(tier == FactoryTier.BASIC && slotID >= 8 && slotID <= 10)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(tier == FactoryTier.ADVANCED && slotID >= 9 && slotID <= 13)
|
||||
else if(tier == FactoryTier.ADVANCED && slotID >= 10 && slotID <= 14)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if(tier == FactoryTier.ELITE && slotID >= 11 && slotID <= 17)
|
||||
else if(tier == FactoryTier.ELITE && slotID >= 12 && slotID <= 18)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -298,33 +344,33 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
if(tier == FactoryTier.BASIC)
|
||||
{
|
||||
if(slotID >= 7 && slotID <= 9)
|
||||
if(slotID >= 8 && slotID <= 10)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(slotID >= 4 && slotID <= 6)
|
||||
else if(slotID >= 5 && slotID <= 7)
|
||||
{
|
||||
return RecipeType.values()[recipeType].getCopiedOutput(itemstack, false) != null;
|
||||
}
|
||||
}
|
||||
else if(tier == FactoryTier.ADVANCED)
|
||||
{
|
||||
if(slotID >= 9 && slotID <= 13)
|
||||
if(slotID >= 10 && slotID <= 14)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(slotID >= 4 && slotID <= 8)
|
||||
else if(slotID >= 5 && slotID <= 9)
|
||||
{
|
||||
return RecipeType.values()[recipeType].getCopiedOutput(itemstack, false) != null;
|
||||
}
|
||||
}
|
||||
else if(tier == FactoryTier.ELITE)
|
||||
{
|
||||
if(slotID >= 11 && slotID <= 17)
|
||||
if(slotID >= 12 && slotID <= 18)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if(slotID >= 4 && slotID <= 10)
|
||||
else if(slotID >= 5 && slotID <= 11)
|
||||
{
|
||||
return RecipeType.values()[recipeType].getCopiedOutput(itemstack, false) != null;
|
||||
}
|
||||
|
@ -338,6 +384,10 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
return ChargeUtils.canBeDischarged(itemstack);
|
||||
}
|
||||
else if(slotID == 4)
|
||||
{
|
||||
return RecipeType.values()[recipeType].getFuelTicks(itemstack) > 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -358,6 +408,11 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
return progress[process]*i / MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED);
|
||||
}
|
||||
|
||||
public int getScaledSecondaryEnergy(int i)
|
||||
{
|
||||
return secondaryEnergyStored*i / getMaxSecondaryEnergy();
|
||||
}
|
||||
|
||||
public int getScaledRecipeProgress(int i)
|
||||
{
|
||||
return recipeTicks*i / RECIPE_TICKS_REQUIRED;
|
||||
|
@ -417,6 +472,11 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
ejectorComponent.onOutput();
|
||||
}
|
||||
|
||||
public void setSecondaryEnergy(int energy)
|
||||
{
|
||||
secondaryEnergyStored = Math.max(Math.min(energy, getMaxSecondaryEnergy()), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(ByteArrayDataInput dataStream)
|
||||
{
|
||||
|
@ -426,6 +486,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
recipeType = dataStream.readInt();
|
||||
recipeTicks = dataStream.readInt();
|
||||
controlType = RedstoneControl.values()[dataStream.readInt()];
|
||||
secondaryEnergyStored = dataStream.readInt();
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -454,6 +515,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
recipeType = nbtTags.getInteger("recipeType");
|
||||
recipeTicks = nbtTags.getInteger("recipeTicks");
|
||||
controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")];
|
||||
secondaryEnergyStored = nbtTags.getInteger("secondaryEnergyStored");
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -478,6 +540,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
nbtTags.setInteger("recipeType", recipeType);
|
||||
nbtTags.setInteger("recipeTicks", recipeTicks);
|
||||
nbtTags.setInteger("controlType", controlType.ordinal());
|
||||
nbtTags.setInteger("secondaryEnergyStored", secondaryEnergyStored);
|
||||
|
||||
for(int i = 0; i < tier.processes; i++)
|
||||
{
|
||||
|
@ -501,6 +564,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
data.add(recipeType);
|
||||
data.add(recipeTicks);
|
||||
data.add(controlType.ordinal());
|
||||
data.add(secondaryEnergyStored);
|
||||
data.add(progress);
|
||||
data.add(sideConfig);
|
||||
|
||||
|
@ -515,12 +579,12 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
|
||||
public int getInputSlot(int operation)
|
||||
{
|
||||
return operation+4;
|
||||
return operation+5;
|
||||
}
|
||||
|
||||
public int getOutputSlot(int operation)
|
||||
{
|
||||
return tier.processes+4+operation;
|
||||
return tier.processes+5+operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -797,4 +861,78 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IEnerg
|
|||
{
|
||||
return ejectorComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGas(EnumGas type, Object... data)
|
||||
{
|
||||
if(type == EnumGas.OXYGEN)
|
||||
{
|
||||
return secondaryEnergyStored;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGas(EnumGas type, int amount, Object... data)
|
||||
{
|
||||
if(type == EnumGas.OXYGEN)
|
||||
{
|
||||
setSecondaryEnergy(amount);
|
||||
}
|
||||
|
||||
MekanismUtils.saveChunk(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxGas(EnumGas type, Object... data)
|
||||
{
|
||||
if(type == EnumGas.OXYGEN)
|
||||
{
|
||||
return getMaxSecondaryEnergy();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int transferGasToAcceptor(int amount, EnumGas type)
|
||||
{
|
||||
if(type == EnumGas.OXYGEN && recipeType == RecipeType.PURIFYING.ordinal())
|
||||
{
|
||||
int rejects = 0;
|
||||
int neededGas = getMaxSecondaryEnergy()-secondaryEnergyStored;
|
||||
|
||||
if(amount <= neededGas)
|
||||
{
|
||||
secondaryEnergyStored += amount;
|
||||
}
|
||||
else if(amount > neededGas)
|
||||
{
|
||||
secondaryEnergyStored += neededGas;
|
||||
rejects = amount-neededGas;
|
||||
}
|
||||
|
||||
return rejects;
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(ForgeDirection side, EnumGas type)
|
||||
{
|
||||
if(recipeType != RecipeType.PURIFYING.ordinal())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return type == EnumGas.OXYGEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(ForgeDirection side)
|
||||
{
|
||||
return recipeType == RecipeType.PURIFYING.ordinal();
|
||||
}
|
||||
}
|
|
@ -110,12 +110,12 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<GasNetwork>
|
|||
{
|
||||
if(type == refGas)
|
||||
{
|
||||
gasScale = Math.min(1, gasScale+.02F);
|
||||
gasScale = Math.min(1, gasScale+.03F);
|
||||
}
|
||||
else if(refGas == null)
|
||||
{
|
||||
refGas = type;
|
||||
gasScale += Math.min(1, gasScale+.02F);
|
||||
gasScale += Math.min(1, gasScale+.03F);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,6 @@ package mekanism.common.tileentity;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import mekanism.api.IStorageTank;
|
||||
import mekanism.api.gas.EnumGas;
|
||||
import mekanism.api.gas.IGasAcceptor;
|
||||
|
@ -15,6 +11,10 @@ import mekanism.common.Mekanism;
|
|||
import mekanism.common.RecipeHandler.Recipe;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMachine implements IGasAcceptor, IGasStorage, ITubeConnection
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
|||
public int getFuelTicks(ItemStack itemstack)
|
||||
{
|
||||
if(itemstack.isItemEqual(new ItemStack(Item.flint))) return 300;
|
||||
if(itemstack.isItemEqual(new ItemStack(Mekanism.GasTank)) && ((IStorageTank)itemstack.getItem()).getGasType(itemstack) == EnumGas.OXYGEN) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -128,6 +129,8 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
|||
setGas(EnumGas.OXYGEN, secondaryEnergyStored + received);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 5.2 KiB |