Work on things!

This commit is contained in:
Aidan Brady 2014-01-18 02:31:36 -05:00
parent 6eb72a7e44
commit a4017fcc0e
8 changed files with 67 additions and 59 deletions

View file

@ -47,15 +47,11 @@ public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler
@Override @Override
public void drawExtras(int i) public void drawExtras(int i)
{ {
float f = ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; /*float f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F;
drawProgressBar(63, 34, 176, 0, 24, 7, f, 0); drawProgressBar(63, 34, 176, 0, 24, 7, f, 0);
f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F; int displayInt = ticksPassed < 20 ? ();
if(ticksPassed < 20) f = 0.0F; displayGauge(61, 37 + 12 - displayInt, 6, displayInt, tileEntity.gasTank.getGas());*/
drawProgressBar(45, 32, 176, 7, 5, 12, f, 3);
f = ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F;
drawProgressBar(149, 12, 176, 19, 4, 52, f, 3);
} }
@Override @Override

View file

@ -85,6 +85,17 @@ public abstract class BaseRecipeHandler extends TemplateRecipeHandler
return false; return false;
} }
public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas)
{
if(gas == null)
{
return;
}
changeTexture(MekanismRenderer.getBlocksTexture());
gui.drawTexturedModelRectFromIcon(xPos, yPos, gas.getGas().getIcon(), sizeX, sizeY);
}
/* /*
* true = usage, false = recipe * true = usage, false = recipe
*/ */

View file

@ -1,5 +1,7 @@
package mekanism.common; package mekanism.common;
import mekanism.api.AdvancedInput;
import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack; import mekanism.api.gas.GasStack;
import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler;
@ -32,21 +34,22 @@ public interface IFactory
public static enum RecipeType public static enum RecipeType
{ {
SMELTING("smelting", "Smelter.ogg", MachineType.ENERGIZED_SMELTER.getStack(), false), SMELTING("smelting", "Smelter.ogg", MachineType.ENERGIZED_SMELTER.getStack(), false, null),
ENRICHING("enriching", "Chamber.ogg", MachineType.ENRICHMENT_CHAMBER.getStack(), false), ENRICHING("enriching", "Chamber.ogg", MachineType.ENRICHMENT_CHAMBER.getStack(), false, Recipe.ENRICHMENT_CHAMBER),
CRUSHING("crushing", "Crusher.ogg", MachineType.CRUSHER.getStack(), false), CRUSHING("crushing", "Crusher.ogg", MachineType.CRUSHER.getStack(), false, Recipe.CRUSHER),
COMPRESSING("compressing", "Compressor.ogg", MachineType.OSMIUM_COMPRESSOR.getStack(), true), COMPRESSING("compressing", "Compressor.ogg", MachineType.OSMIUM_COMPRESSOR.getStack(), true, Recipe.OSMIUM_COMPRESSOR),
COMBINING("combining", "Combiner.ogg", MachineType.COMBINER.getStack(), true), COMBINING("combining", "Combiner.ogg", MachineType.COMBINER.getStack(), true, Recipe.COMBINER),
PURIFYING("purifying", "PurificationChamber.ogg", MachineType.PURIFICATION_CHAMBER.getStack(), true), PURIFYING("purifying", "PurificationChamber.ogg", MachineType.PURIFICATION_CHAMBER.getStack(), true, Recipe.PURIFICATION_CHAMBER),
INJECTING("injecting", "ChemicalInjectionChamber.ogg", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true); INJECTING("injecting", "ChemicalInjectionChamber.ogg", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, Recipe.CHEMICAL_INJECTION_CHAMBER);
private String name; private String name;
private String sound; private String sound;
private ItemStack stack; private ItemStack stack;
private boolean usesFuel; private boolean usesFuel;
private Recipe recipe;
private TileEntityAdvancedElectricMachine cacheTile; private TileEntityAdvancedElectricMachine cacheTile;
public ItemStack getCopiedOutput(ItemStack input, boolean stackDecrease) public ItemStack getCopiedOutput(ItemStack input, Gas gas, boolean stackDecrease)
{ {
if(input == null) if(input == null)
{ {
@ -66,33 +69,17 @@ public interface IFactory
return toReturn; return toReturn;
} }
}
else if(this == ENRICHING) return null;
{
return RecipeHandler.getOutput(input, stackDecrease, Recipe.ENRICHMENT_CHAMBER.get());
}
else if(this == CRUSHING)
{
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());
}
else if(this == INJECTING)
{
return RecipeHandler.getOutput(input, stackDecrease, Recipe.CHEMICAL_INJECTION_CHAMBER.get());
} }
return null; if(usesFuel())
{
return RecipeHandler.getOutput(new AdvancedInput(input, gas), stackDecrease, recipe.get());
}
else {
return RecipeHandler.getOutput(input, stackDecrease, recipe.get());
}
} }
public GasStack getItemGas(ItemStack itemstack) public GasStack getItemGas(ItemStack itemstack)
@ -151,12 +138,13 @@ public interface IFactory
return usesFuel; return usesFuel;
} }
private RecipeType(String s, String s1, ItemStack is, boolean b) private RecipeType(String s, String s1, ItemStack is, boolean b, Recipe r)
{ {
name = s; name = s;
sound = s1; sound = s1;
stack = is; stack = is;
usesFuel = b; usesFuel = b;
recipe = r;
} }
} }
} }

View file

@ -237,15 +237,15 @@ public final class OreDictManager
for(ItemStack ore : OreDictionary.getOres("oreIron")) for(ItemStack ore : OreDictionary.getOres("oreIron"))
{ {
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreIron), new ItemStack(Mekanism.Dust, 2, 0)); RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 0));
RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreIron), new ItemStack(Mekanism.Clump, 3, 0)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 0));
RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Shard, 4, 0)); RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Shard, 4, 0));
} }
for(ItemStack ore : OreDictionary.getOres("oreGold")) for(ItemStack ore : OreDictionary.getOres("oreGold"))
{ {
RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Mekanism.Dust, 2, 1)); RecipeHandler.addEnrichmentChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Dust, 2, 1));
RecipeHandler.addPurificationChamberRecipe(new ItemStack(Block.oreGold), new ItemStack(Mekanism.Clump, 3, 1)); RecipeHandler.addPurificationChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Clump, 3, 1));
RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Shard, 4, 1)); RecipeHandler.addChemicalInjectionChamberRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Shard, 4, 1));
} }

View file

@ -1,14 +1,14 @@
package mekanism.common.inventory.container; package mekanism.common.inventory.container;
import mekanism.api.gas.IGasItem; import java.util.Map;
import mekanism.common.Mekanism;
import mekanism.api.AdvancedInput;
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
import mekanism.common.inventory.slot.SlotMachineUpgrade; import mekanism.common.inventory.slot.SlotMachineUpgrade;
import mekanism.common.inventory.slot.SlotOutput; import mekanism.common.inventory.slot.SlotOutput;
import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge;
import mekanism.common.item.ItemMachineUpgrade; import mekanism.common.item.ItemMachineUpgrade;
import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler;
import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.tile.TileEntityAdvancedElectricMachine;
import mekanism.common.tile.TileEntityPurificationChamber;
import mekanism.common.util.ChargeUtils; import mekanism.common.util.ChargeUtils;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
@ -113,7 +113,7 @@ public class ContainerAdvancedElectricMachine extends Container
} }
} }
} }
else if(RecipeHandler.getOutput(slotStack, false, tileEntity.getRecipes()) != null) else if(isInputItem(slotStack))
{ {
if(slotID != 0) if(slotID != 0)
{ {
@ -186,4 +186,17 @@ public class ContainerAdvancedElectricMachine extends Container
return stack; return stack;
} }
private boolean isInputItem(ItemStack itemstack)
{
for(Map.Entry<AdvancedInput, ItemStack> entry : ((Map<AdvancedInput, ItemStack>)tileEntity.getRecipes()).entrySet())
{
if(entry.getKey().itemStack.isItemEqual(itemstack))
{
return true;
}
}
return false;
}
} }

View file

@ -179,7 +179,7 @@ public class ContainerFactory extends Container
} }
} }
} }
else if(RecipeType.values()[tileEntity.recipeType].getCopiedOutput(slotStack, false) != null) else if(RecipeType.values()[tileEntity.recipeType].getCopiedOutput(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null, false) != null)
{ {
if(!isInputSlot(slotID)) if(!isInputSlot(slotID))
{ {

View file

@ -97,15 +97,15 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
operatingTicks++; operatingTicks++;
gasTank.draw(SECONDARY_ENERGY_PER_TICK, true);
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
if(operatingTicks >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED)) if(operatingTicks >= MekanismUtils.getTicks(getSpeedMultiplier(), TICKS_REQUIRED))
{ {
operate(); operate();
operatingTicks = 0; operatingTicks = 0;
} }
gasTank.draw(SECONDARY_ENERGY_PER_TICK, true);
electricityStored -= MekanismUtils.getEnergyPerTick(getSpeedMultiplier(), getEnergyMultiplier(), ENERGY_PER_TICK);
} }
else { else {
if(prevEnergy >= getEnergy()) if(prevEnergy >= getEnergy())

View file

@ -420,7 +420,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
} }
else if(slotID >= 5 && slotID <= 7) else if(slotID >= 5 && slotID <= 7)
{ {
return RecipeType.values()[recipeType].getCopiedOutput(itemstack, false) != null; return RecipeType.values()[recipeType].getCopiedOutput(itemstack, gasTank.getGas() != null ? gasTank.getGas().getGas() : null, false) != null;
} }
} }
else if(tier == FactoryTier.ADVANCED) else if(tier == FactoryTier.ADVANCED)
@ -431,7 +431,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
} }
else if(slotID >= 5 && slotID <= 9) else if(slotID >= 5 && slotID <= 9)
{ {
return RecipeType.values()[recipeType].getCopiedOutput(itemstack, false) != null; return RecipeType.values()[recipeType].getCopiedOutput(itemstack, gasTank.getGas() != null ? gasTank.getGas().getGas() : null, false) != null;
} }
} }
else if(tier == FactoryTier.ELITE) else if(tier == FactoryTier.ELITE)
@ -442,7 +442,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
} }
else if(slotID >= 5 && slotID <= 11) else if(slotID >= 5 && slotID <= 11)
{ {
return RecipeType.values()[recipeType].getCopiedOutput(itemstack, false) != null; return RecipeType.values()[recipeType].getCopiedOutput(itemstack, gasTank.getGas() != null ? gasTank.getGas().getGas() : null, false) != null;
} }
} }
@ -495,7 +495,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
return false; return false;
} }
ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], false); ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, false);
if(itemstack == null) if(itemstack == null)
{ {
@ -523,7 +523,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
return; return;
} }
ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], true); ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, true);
if(inventory[inputSlot].stackSize <= 0) if(inventory[inputSlot].stackSize <= 0)
{ {