*Fixed NEI overlay paths.

*Modularized Smelting Factories, now named only Factories and can
crush, smelt, or enrich.
*Fixed machine wrench drops.
This commit is contained in:
Aidan Brady 2013-03-20 11:14:26 -04:00
parent 6800c4dcc4
commit d6cdfb00cf
28 changed files with 756 additions and 143 deletions

View file

@ -0,0 +1,74 @@
package mekanism.api;
import mekanism.common.RecipeHandler;
import mekanism.common.RecipeHandler.Recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
public interface IFactory
{
/**
* Gets the recipe type this Smelting Factory currently has.
* @param itemStack - stack to check
* @return RecipeType ordinal
*/
public int getRecipeType(ItemStack itemStack);
/**
* Sets the recipe type of this Smelting Factory to a new value.
* @param type - RecipeType ordinal
* @param itemStack - stack to set
*/
public void setRecipeType(int type, ItemStack itemStack);
/**
* Whether or not this item is a Smelting Factory.
* @param itemStack - stack to check
* @return if the item is a smelting factory
*/
public boolean isFactory(ItemStack itemStack);
public static enum RecipeType
{
SMELTING("Smelting"),
ENRICHING("Enriching"),
CRUSHING("Crushing");
private String name;
public ItemStack getCopiedOutput(ItemStack input, boolean stackDecrease)
{
if(this == SMELTING)
{
ItemStack toReturn = FurnaceRecipes.smelting().getSmeltingResult(input).copy();
if(stackDecrease)
{
input.stackSize--;
}
return toReturn;
}
else if(this == ENRICHING)
{
return RecipeHandler.getOutput(input, stackDecrease, Recipe.ENRICHMENT_CHAMBER.get());
}
else if(this == CRUSHING)
{
return RecipeHandler.getOutput(input, stackDecrease, Recipe.CRUSHER.get());
}
return null;
}
public String getName()
{
return name;
}
private RecipeType(String s)
{
name = s;
}
}
}

View file

@ -52,7 +52,7 @@ public final class Tier
* @author aidancbrady
*
*/
public static enum SmeltingFactoryTier
public static enum FactoryTier
{
BASIC("Basic", 3, "GuiBasicSmeltingFactory.png"),
ADVANCED("Advanced", 5, "GuiAdvancedSmeltingFactory.png"),
@ -62,9 +62,9 @@ public final class Tier
public String guiTexturePath;
public String name;
public static SmeltingFactoryTier getFromName(String tierName)
public static FactoryTier getFromName(String tierName)
{
for(SmeltingFactoryTier tier : values())
for(FactoryTier tier : values())
{
if(tierName.contains(tier.name))
{
@ -76,7 +76,7 @@ public final class Tier
return BASIC;
}
private SmeltingFactoryTier(String s, int process, String gui)
private FactoryTier(String s, int process, String gui)
{
name = s;
processes = process;

View file

@ -14,7 +14,7 @@ import mekanism.common.TileEntityGasTank;
import mekanism.common.TileEntityMetallurgicInfuser;
import mekanism.common.TileEntityPressurizedTube;
import mekanism.common.TileEntityPurificationChamber;
import mekanism.common.TileEntitySmeltingFactory;
import mekanism.common.TileEntityFactory;
import mekanism.common.TileEntityTeleporter;
import mekanism.common.TileEntityTheoreticalElementizer;
import mekanism.generators.client.ModelAdvancedSolarGenerator;
@ -138,7 +138,7 @@ public class ClientProxy extends CommonProxy
case 10:
return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity);
case 11:
return new GuiSmeltingFactory(player.inventory, (TileEntitySmeltingFactory)tileEntity);
return new GuiFactory(player.inventory, (TileEntityFactory)tileEntity);
case 12:
return new GuiMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity);
case 13:

View file

@ -1,18 +1,19 @@
package mekanism.client;
import mekanism.api.Tier.SmeltingFactoryTier;
import mekanism.api.IFactory.RecipeType;
import mekanism.api.Tier.FactoryTier;
import mekanism.common.ContainerSmeltingFactory;
import mekanism.common.TileEntitySmeltingFactory;
import mekanism.common.TileEntityFactory;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import org.lwjgl.opengl.GL11;
public class GuiSmeltingFactory extends GuiContainer
public class GuiFactory extends GuiContainer
{
public TileEntitySmeltingFactory tileEntity;
public TileEntityFactory tileEntity;
public GuiSmeltingFactory(InventoryPlayer inventory, TileEntitySmeltingFactory tentity)
public GuiFactory(InventoryPlayer inventory, TileEntityFactory tentity)
{
super(new ContainerSmeltingFactory(inventory, tentity));
xSize+=26;
@ -22,8 +23,9 @@ public class GuiSmeltingFactory extends GuiContainer
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
fontRenderer.drawString(tileEntity.fullName, 34, 4, 0x404040);
fontRenderer.drawString(tileEntity.fullName, 48, 4, 0x404040);
fontRenderer.drawString("Inventory", 8, (ySize - 93) + 2, 0x404040);
fontRenderer.drawString(RecipeType.values()[tileEntity.recipeType].getName(), 124, (ySize - 93) + 2, 0x404040);
fontRenderer.drawString("S:" + (tileEntity.speedMultiplier+1) + "x", 179, 47, 0x404040);
fontRenderer.drawString("E:" + (tileEntity.energyMultiplier+1) + "x", 179, 57, 0x404040);
}
@ -45,7 +47,7 @@ public class GuiSmeltingFactory extends GuiContainer
displayInt = tileEntity.getScaledUpgradeProgress(14);
drawTexturedModalRect(guiWidth + 180, guiHeight + 30, 176 + 26, 72, 10, displayInt);
if(tileEntity.tier == SmeltingFactoryTier.BASIC)
if(tileEntity.tier == FactoryTier.BASIC)
{
for(int i = 0; i < tileEntity.tier.processes; i++)
{
@ -55,7 +57,7 @@ public class GuiSmeltingFactory extends GuiContainer
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176 + 26, 52, 8, displayInt);
}
}
else if(tileEntity.tier == SmeltingFactoryTier.ADVANCED)
else if(tileEntity.tier == FactoryTier.ADVANCED)
{
for(int i = 0; i < tileEntity.tier.processes; i++)
{
@ -65,7 +67,7 @@ public class GuiSmeltingFactory extends GuiContainer
drawTexturedModalRect(guiWidth + xAxis, guiHeight + 33, 176 + 26, 52, 8, displayInt);
}
}
else if(tileEntity.tier == SmeltingFactoryTier.ELITE)
else if(tileEntity.tier == FactoryTier.ELITE)
{
for(int i = 0; i < tileEntity.tier.processes; i++)
{

View file

@ -11,6 +11,9 @@ import universalelectricity.prefab.implement.IToolConfigurator;
import mekanism.api.IActiveState;
import mekanism.api.IEnergyCube;
import mekanism.api.IFactory;
import mekanism.api.Tier;
import mekanism.api.IFactory.RecipeType;
import mekanism.api.IUpgradeManagement;
import mekanism.client.ClientProxy;
import net.minecraft.block.BlockContainer;
@ -40,9 +43,9 @@ import cpw.mods.fml.relauncher.SideOnly;
* 2: Combiner
* 3: Crusher
* 4: Theoretical Elementizer
* 5: Basic Smelting Factory
* 6: Advanced Smelting Factory
* 7: Elite Smelting Factory
* 5: Basic Factory
* 6: Advanced Factory
* 7: Elite Factory
* 8: Metallurgic Infuser
* 9: Purification Chamber
* @author AidanBrady
@ -79,12 +82,12 @@ public class BlockMachine extends BlockContainer implements IDismantleable
icons[5][0] = register.func_94245_a("mekanism:BasicSmeltingFactoryFront");
icons[5][1] = register.func_94245_a("mekanism:BasicSmeltingFactorySide");
icons[5][2] = register.func_94245_a("mekanism:BasicSmeltingFactoryTop");
icons[6][0] = register.func_94245_a("mekanism:AdvancedSmeltingFactoryFront");
icons[6][1] = register.func_94245_a("mekanism:AdvancedSmeltingFactorySide");
icons[6][2] = register.func_94245_a("mekanism:AdvancedSmeltingFactoryTop");
icons[7][0] = register.func_94245_a("mekanism:EliteSmeltingFactoryFront");
icons[7][1] = register.func_94245_a("mekanism:EliteSmeltingFactorySide");
icons[7][2] = register.func_94245_a("mekanism:EliteSmeltingFactoryTop");
icons[6][0] = register.func_94245_a("mekanism:AdvancedFactoryFront");
icons[6][1] = register.func_94245_a("mekanism:AdvancedFactorySide");
icons[6][2] = register.func_94245_a("mekanism:AdvancedFactoryTop");
icons[7][0] = register.func_94245_a("mekanism:EliteFactoryFront");
icons[7][1] = register.func_94245_a("mekanism:EliteFactorySide");
icons[7][2] = register.func_94245_a("mekanism:EliteFactoryTop");
icons[8][0] = register.func_94245_a("mekanism:MetallurgicInfuserFrontOff");
icons[8][1] = register.func_94245_a("mekanism:MetallurgicInfuserFrontOn");
icons[8][2] = register.func_94245_a("mekanism:MetallurgicInfuserSideOff");
@ -433,9 +436,16 @@ public class BlockMachine extends BlockContainer implements IDismantleable
list.add(new ItemStack(i, 1, 4));
}
list.add(new ItemStack(i, 1, 5));
list.add(new ItemStack(i, 1, 6));
list.add(new ItemStack(i, 1, 7));
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);
}
}
list.add(new ItemStack(i, 1, 8));
list.add(new ItemStack(i, 1, 9));
}
@ -623,6 +633,12 @@ public class BlockMachine extends BlockContainer implements IDismantleable
IItemElectric electricItem = (IItemElectric)entityItem.getEntityItem().getItem();
electricItem.setJoules(tileEntity.electricityStored, entityItem.getEntityItem());
if(tileEntity instanceof TileEntityFactory)
{
IFactory factoryItem = (IFactory)entityItem.getEntityItem().getItem();
factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, entityItem.getEntityItem());
}
world.spawnEntityInWorld(entityItem);
}
@ -648,6 +664,12 @@ public class BlockMachine extends BlockContainer implements IDismantleable
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
electricItem.setJoules(tileEntity.electricityStored, itemStack);
if(tileEntity instanceof TileEntityFactory)
{
IFactory factoryItem = (IFactory)itemStack.getItem();
factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack);
}
return itemStack;
}
@ -664,6 +686,12 @@ public class BlockMachine extends BlockContainer implements IDismantleable
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
electricItem.setJoules(tileEntity.electricityStored, itemStack);
if(tileEntity instanceof TileEntityFactory)
{
IFactory factoryItem = (IFactory)itemStack.getItem();
factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack);
}
world.func_94571_i(x, y, z);
if(!returnBlock)
@ -694,9 +722,9 @@ public class BlockMachine extends BlockContainer implements IDismantleable
COMBINER(2, 5, 2000, TileEntityCombiner.class, false),
CRUSHER(3, 6, 2000, TileEntityCrusher.class, false),
THEORETICAL_ELEMENTIZER(4, 7, 4800, TileEntityTheoreticalElementizer.class, true),
BASIC_SMELTING_FACTORY(5, 11, 6000, TileEntitySmeltingFactory.class, false),
ADVANCED_SMELTING_FACTORY(6, 11, 10000, TileEntityAdvancedSmeltingFactory.class, false),
ELITE_SMELTING_FACTORY(7, 11, 14000, TileEntityEliteSmeltingFactory.class, false),
BASIC_FACTORY(5, 11, 6000, TileEntityFactory.class, false),
ADVANCED_FACTORY(6, 11, 10000, TileEntityAdvancedFactory.class, false),
ELITE_FACTORY(7, 11, 14000, TileEntityEliteFactory.class, false),
METALLURGIC_INFUSER(8, 12, 2000, TileEntityMetallurgicInfuser.class, false),
PURIFICATION_CHAMBER(9, 15, 12000, TileEntityPurificationChamber.class, false);

View file

@ -146,7 +146,7 @@ public class CommonProxy
case 10:
return new ContainerGasTank(player.inventory, (TileEntityGasTank)tileEntity);
case 11:
return new ContainerSmeltingFactory(player.inventory, (TileEntitySmeltingFactory)tileEntity);
return new ContainerSmeltingFactory(player.inventory, (TileEntityFactory)tileEntity);
case 12:
return new ContainerMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity);
case 13:

View file

@ -3,7 +3,8 @@ package mekanism.common;
import universalelectricity.core.item.IItemElectric;
import ic2.api.IElectricItem;
import mekanism.api.Tier;
import mekanism.api.Tier.SmeltingFactoryTier;
import mekanism.api.IFactory.RecipeType;
import mekanism.api.Tier.FactoryTier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@ -15,16 +16,16 @@ import net.minecraft.item.crafting.FurnaceRecipes;
public class ContainerSmeltingFactory extends Container
{
private TileEntitySmeltingFactory tileEntity;
private TileEntityFactory tileEntity;
public ContainerSmeltingFactory(InventoryPlayer inventory, TileEntitySmeltingFactory tentity)
public ContainerSmeltingFactory(InventoryPlayer inventory, TileEntityFactory tentity)
{
tileEntity = tentity;
addSlotToContainer(new SlotMachineUpgrade(tentity, 0, 180, 11));
addSlotToContainer(new SlotEnergy(tentity, 1, 7, 35));
if(tileEntity.tier == SmeltingFactoryTier.BASIC)
if(tileEntity.tier == FactoryTier.BASIC)
{
for(int i = 0; i < tileEntity.tier.processes; i++)
{
@ -40,7 +41,7 @@ public class ContainerSmeltingFactory extends Container
addSlotToContainer(new SlotFurnace(inventory.player, tentity, tileEntity.tier.processes+2+i, xAxis, 57));
}
}
else if(tileEntity.tier == SmeltingFactoryTier.ADVANCED)
else if(tileEntity.tier == FactoryTier.ADVANCED)
{
for(int i = 0; i < tileEntity.tier.processes; i++)
{
@ -56,7 +57,7 @@ public class ContainerSmeltingFactory extends Container
addSlotToContainer(new SlotFurnace(inventory.player, tentity, tileEntity.tier.processes+2+i, xAxis, 57));
}
}
else if(tileEntity.tier == SmeltingFactoryTier.ELITE)
else if(tileEntity.tier == FactoryTier.ELITE)
{
for(int i = 0; i < tileEntity.tier.processes; i++)
{
@ -139,7 +140,7 @@ public class ContainerSmeltingFactory extends Container
}
}
}
else if(FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null)
else if(RecipeType.values()[tileEntity.recipeType].getCopiedOutput(slotStack, false) != null)
{
if(!isInputSlot(slotID))
{
@ -218,11 +219,11 @@ public class ContainerSmeltingFactory extends Container
public boolean isInputSlot(int slot)
{
if(tileEntity.tier == Tier.SmeltingFactoryTier.BASIC)
if(tileEntity.tier == Tier.FactoryTier.BASIC)
return slot >= 2 && slot <= 4;
if(tileEntity.tier == Tier.SmeltingFactoryTier.ADVANCED)
if(tileEntity.tier == Tier.FactoryTier.ADVANCED)
return slot >= 2 && slot <= 6;
if(tileEntity.tier == Tier.SmeltingFactoryTier.ELITE)
if(tileEntity.tier == Tier.FactoryTier.ELITE)
return slot >= 2 && slot <= 8;
return false;
@ -230,11 +231,11 @@ public class ContainerSmeltingFactory extends Container
public boolean isOutputSlot(int slot)
{
if(tileEntity.tier == Tier.SmeltingFactoryTier.BASIC)
if(tileEntity.tier == Tier.FactoryTier.BASIC)
return slot >= 5 && slot <= 7;
if(tileEntity.tier == Tier.SmeltingFactoryTier.ADVANCED)
if(tileEntity.tier == Tier.FactoryTier.ADVANCED)
return slot >= 7 && slot <= 11;
if(tileEntity.tier == Tier.SmeltingFactoryTier.ELITE)
if(tileEntity.tier == Tier.FactoryTier.ELITE)
return slot >= 9 && slot <= 15;
return false;

View file

@ -0,0 +1,299 @@
package mekanism.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import mekanism.api.IFactory;
import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
/**
* Code originally from Eloraam and her work on the Ore Dictionary. Cleaned up and modified to work with Factory recipe types.
* @author Eloraam, aidancbrady
*
*/
public class FactoryRecipe implements IRecipe
{
//Added in for future ease of change, but hard coded for now.
private static final int MAX_CRAFT_GRID_WIDTH = 3;
private static final int MAX_CRAFT_GRID_HEIGHT = 3;
private ItemStack output = null;
private Object[] input = null;
private int width = 0;
private int height = 0;
private boolean mirrored = true;
public FactoryRecipe(Block result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public FactoryRecipe(Item result, Object... recipe)
{
this(new ItemStack(result), recipe);
}
public FactoryRecipe(ItemStack result, Object... recipe)
{
output = result.copy();
String shape = "";
int idx = 0;
if(recipe[idx] instanceof Boolean)
{
mirrored = (Boolean)recipe[idx];
if (recipe[idx+1] instanceof Object[])
{
recipe = (Object[])recipe[idx+1];
}
else
{
idx = 1;
}
}
if(recipe[idx] instanceof String[])
{
String[] parts = ((String[])recipe[idx++]);
for(String s : parts)
{
width = s.length();
shape += s;
}
height = parts.length;
}
else {
while(recipe[idx] instanceof String)
{
String s = (String)recipe[idx++];
shape += s;
width = s.length();
height++;
}
}
if(width * height != shape.length())
{
String ret = "Invalid shaped ore recipe: ";
for (Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
throw new RuntimeException(ret);
}
HashMap<Character, Object> itemMap = new HashMap<Character, Object>();
for(; idx < recipe.length; idx += 2)
{
Character chr = (Character)recipe[idx];
Object in = recipe[idx + 1];
if(in instanceof ItemStack)
{
itemMap.put(chr, ((ItemStack)in).copy());
}
else if(in instanceof Item)
{
itemMap.put(chr, new ItemStack((Item)in));
}
else if(in instanceof Block)
{
itemMap.put(chr, new ItemStack((Block)in, 1, OreDictionary.WILDCARD_VALUE));
}
else if(in instanceof String)
{
itemMap.put(chr, OreDictionary.getOres((String)in));
}
else {
String ret = "Invalid shaped ore recipe: ";
for(Object tmp : recipe)
{
ret += tmp + ", ";
}
ret += output;
throw new RuntimeException(ret);
}
}
input = new Object[width * height];
int x = 0;
for(char chr : shape.toCharArray())
{
input[x++] = itemMap.get(chr);
}
}
FactoryRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
{
output = recipe.getRecipeOutput();
width = recipe.recipeWidth;
height = recipe.recipeHeight;
input = new Object[recipe.recipeItems.length];
for(int i = 0; i < input.length; i++)
{
ItemStack ingred = recipe.recipeItems[i];
if(ingred == null) continue;
input[i] = recipe.recipeItems[i];
for(Entry<ItemStack, String> replace : replacements.entrySet())
{
if(OreDictionary.itemMatches(replace.getKey(), ingred, true))
{
input[i] = OreDictionary.getOres(replace.getValue());
break;
}
}
}
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inv)
{
return output.copy();
}
@Override
public int getRecipeSize()
{
return input.length;
}
@Override
public ItemStack getRecipeOutput()
{
return output;
}
@Override
public boolean matches(InventoryCrafting inv, World world)
{
for(int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++)
{
for(int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y)
{
if(checkMatch(inv, x, y, true))
{
return true;
}
if(mirrored && checkMatch(inv, x, y, false))
{
return true;
}
}
}
return false;
}
private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror)
{
for(int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
{
for(int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
{
int subX = x - startX;
int subY = y - startY;
Object target = null;
if(subX >= 0 && subY >= 0 && subX < width && subY < height)
{
if(mirror)
{
target = input[width - subX - 1 + subY * width];
}
else {
target = input[subX + subY * width];
}
}
ItemStack slot = inv.getStackInRowAndColumn(x, y);
if(target instanceof ItemStack)
{
if(!checkItemEquals((ItemStack)target, slot))
{
return false;
}
}
else if(target instanceof ArrayList)
{
boolean matched = false;
for(ItemStack item : (ArrayList<ItemStack>)target)
{
matched = matched || checkItemEquals(item, slot);
}
if(!matched)
{
return false;
}
}
else if(target == null && slot != null)
{
return false;
}
}
}
return true;
}
private boolean checkItemEquals(ItemStack target, ItemStack input)
{
if(input == null && target != null || input != null && target == null)
{
return false;
}
if(target.itemID != input.itemID || target.getItemDamage() != input.getItemDamage())
{
return false;
}
if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory)
{
if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input))
{
return false;
}
}
return true;
}
public FactoryRecipe setMirrored(boolean mirror)
{
mirrored = mirror;
return this;
}
/**
* Returns the input for this recipe, any mod accessing this value should never
* manipulate the values in this array as it will effect the recipe itself.
* @return The recipes input vales.
*/
public Object[] getInput()
{
return this.input;
}
}

View file

@ -8,6 +8,7 @@ import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
import universalelectricity.core.item.IItemElectric;
import ic2.api.ICustomElectricItem;
import mekanism.api.IFactory;
import mekanism.api.IUpgradeManagement;
import mekanism.common.BlockMachine.MachineType;
import net.minecraft.block.Block;
@ -26,15 +27,15 @@ import net.minecraft.world.World;
* 2: Combiner
* 3: Crusher
* 4: Theoretical Elementizer
* 5: Basic Smelting Factory
* 6: Advanced Smelting Factory
* 7: Elite Smelting Factory
* 5: Basic Factory
* 6: Advanced Factory
* 7: Elite Factory
* 8: Metallurgic Infuser
* 9: Purification Chamber
* @author AidanBrady
*
*/
public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICustomElectricItem, IUpgradeManagement
public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICustomElectricItem, IUpgradeManagement, IFactory
{
public Block metaBlock;
@ -75,13 +76,13 @@ public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICusto
name = "TheoreticalElementizer";
break;
case 5:
name = "BasicSmeltingFactory";
name = "BasicFactory";
break;
case 6:
name = "AdvancedSmeltingFactory";
name = "AdvancedFactory";
break;
case 7:
name = "EliteSmeltingFactory";
name = "EliteFactory";
break;
case 8:
name = "MetallurgicInfuser";
@ -101,6 +102,11 @@ public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICusto
{
double energy = getJoules(itemstack);
if(isFactory(itemstack))
{
list.add("Recipe Type: " + RecipeType.values()[getRecipeType(itemstack)].getName());
}
list.add("Stored Energy: " + ElectricityDisplay.getDisplayShort(energy, ElectricUnit.JOULES));
list.add("Energy: x" + (getEnergyMultiplier(itemstack)+1));
list.add("Speed: x" + (getSpeedMultiplier(itemstack)+1));
@ -200,6 +206,11 @@ public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICusto
((IUpgradeManagement)tileEntity).setSpeedMultiplier(getSpeedMultiplier(stack));
}
if(tileEntity instanceof TileEntityFactory)
{
((TileEntityFactory)tileEntity).recipeType = getRecipeType(stack);
}
tileEntity.electricityStored = getJoules(stack);
}
@ -348,4 +359,32 @@ public class ItemBlockMachine extends ItemBlock implements IItemElectric, ICusto
itemStack.stackTagCompound.setInteger("speedMultiplier", multiplier);
}
}
@Override
public int getRecipeType(ItemStack itemStack)
{
if(itemStack.stackTagCompound == null)
{
return 0;
}
return itemStack.stackTagCompound.getInteger("recipeType");
}
@Override
public void setRecipeType(int type, ItemStack itemStack)
{
if(itemStack.stackTagCompound == null)
{
itemStack.setTagCompound(new NBTTagCompound());
}
itemStack.stackTagCompound.setInteger("recipeType", type);
}
@Override
public boolean isFactory(ItemStack itemStack)
{
return itemStack.getItem() instanceof ItemBlockMachine && itemStack.getItemDamage() >= 5 && itemStack.getItemDamage() <= 7;
}
}

View file

@ -8,12 +8,14 @@ import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import mekanism.api.IFactory.RecipeType;
import mekanism.api.InfuseObject;
import mekanism.api.InfusionInput;
import mekanism.api.InfusionOutput;
import mekanism.api.InfusionType;
import mekanism.api.RecipeHelper;
import mekanism.api.Tier.EnergyCubeTier;
import mekanism.api.Tier.FactoryTier;
import mekanism.client.SoundHandler;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
@ -258,17 +260,17 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(GasTank, new Object[] {
"PPP", "PDP", "PPP", Character.valueOf('P'), "ingotOsmium", Character.valueOf('D'), "dustIron"
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.BASIC), new Object[] {
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), new Object[] {
"RLR", "TIT", "RLR", Character.valueOf('R'), Item.redstone, Character.valueOf('L'), new ItemStack(Item.dyePowder, 1, 4), Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('I'), "blockSteel"
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ADVANCED), new Object[] {
"EGE", "TBT", "EGE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('G'), Item.ingotGold, Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('B'), MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.BASIC)
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED), new Object[] {
"EGE", "TBT", "EGE", Character.valueOf('E'), EnrichedAlloy, Character.valueOf('G'), Item.ingotGold, Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('B'), MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC)
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ELITE), new Object[] {
"CDC", "TAT", "CDC", Character.valueOf('C'), "basicCircuit", Character.valueOf('D'), Item.diamond, Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('A'), MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ADVANCED)
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE), new Object[] {
"CDC", "TAT", "CDC", Character.valueOf('C'), "basicCircuit", Character.valueOf('D'), Item.diamond, Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('A'), MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED)
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ULTIMATE), new Object[] {
"COC", "TAT", "COC", Character.valueOf('C'), AtomicCore, Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('A'), MekanismUtils.getEnergyCubeWithTier(EnergyCubeTier.ELITE)
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.ULTIMATE), new Object[] {
"COC", "TAT", "COC", Character.valueOf('C'), AtomicCore, Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('T'), EnergyTablet.getUnchargedItem(), Character.valueOf('A'), MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE)
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(ControlCircuit), new Object[] {
" P ", "PEP", " P ", Character.valueOf('P'), "ingotOsmium", Character.valueOf('E'), EnrichedAlloy
@ -282,18 +284,6 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(EnrichedIron, 4), new Object[] {
"T", "I", "T", Character.valueOf('T'), "dustTin", Character.valueOf('I'), Item.ingotIron
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 5), new Object[] {
"CAC", "GIG", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('I'), "blockSteel"
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 6), new Object[] {
"CAC", "DFD", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('D'), "dustDiamond", Character.valueOf('F'), new ItemStack(MachineBlock, 1, 5)
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 7), new Object[] {
"CAC", "cFc", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('F'), new ItemStack(MachineBlock, 1, 6)
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 7), new Object[] {
"CAC", "cFc", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('F'), "electricFurnace"
}));
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 8), new Object[] {
"IFI", "CEC", "IFI", Character.valueOf('I'), Item.ingotIron, Character.valueOf('F'), Block.furnaceIdle, Character.valueOf('C'), "basicCircuit", Character.valueOf('E'), EnrichedAlloy
}));
@ -319,6 +309,27 @@ public class Mekanism
"IAI", "PPP", "IAI", Character.valueOf('I'), Item.ingotIron, Character.valueOf('A'), EnrichedAlloy, Character.valueOf('P'), "dustOsmium"
}));
//Factory Recipes
CraftingManager.getInstance().getRecipeList().add(new FactoryRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.SMELTING), new Object[] {
"CAC", "GOG", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('O'), Block.furnaceIdle
}));
CraftingManager.getInstance().getRecipeList().add(new FactoryRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.ENRICHING), new Object[] {
"CAC", "GOG", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('G'), "dustGold", Character.valueOf('O'), new ItemStack(MachineBlock, 1, 0)
}));
CraftingManager.getInstance().getRecipeList().add(new FactoryRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, RecipeType.CRUSHING), new Object[] {
"CAC", "GOG", "CAC", Character.valueOf('C'), "basicCircuit", 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 FactoryRecipe(MekanismUtils.getFactory(FactoryTier.ADVANCED, type), new Object[] {
"CAC", "DOD", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('D'), "dustDiamond", Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.BASIC, type)
}));
CraftingManager.getInstance().getRecipeList().add(new FactoryRecipe(MekanismUtils.getFactory(FactoryTier.ELITE, type), new Object[] {
"CAC", "cOc", "CAC", Character.valueOf('C'), "basicCircuit", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('c'), AtomicCore, Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.ADVANCED, type)
}));
}
if(extrasEnabled)
{
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(MachineBlock, 1, 4), new Object[] {
@ -432,9 +443,9 @@ public class Mekanism
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.Combiner.name", "Combiner");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.Crusher.name", "Crusher");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.TheoreticalElementizer.name", "Theoretical Elementizer");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.BasicSmeltingFactory.name", "Basic Smelting Factory");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.AdvancedSmeltingFactory.name", "Advanced Smelting Factory");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.EliteSmeltingFactory.name", "Elite Smelting Factory");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.BasicFactory.name", "Basic Factory");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.AdvancedFactory.name", "Advanced Factory");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.EliteFactory.name", "Elite Factory");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.MetallurgicInfuser.name", "Metallurgic Infuser");
LanguageRegistry.instance().addStringLocalization("tile.MachineBlock.PurificationChamber.name", "Purification Chamber");
@ -811,6 +822,11 @@ public class Mekanism
RecipeHandler.addCombinerRecipe(MekanismUtils.getStackWithSize(ore, 8), new ItemStack(Block.oreIron));
}
for(ItemStack ore : OreDictionary.getOres("ingotSteel"))
{
RecipeHandler.addCrusherRecipe(MekanismUtils.getStackWithSize(ore, 1), new ItemStack(Dust, 1, 5));
}
for(ItemStack ore : OreDictionary.getOres("dustGold"))
{
RecipeHandler.addCombinerRecipe(MekanismUtils.getStackWithSize(ore, 8), new ItemStack(Block.oreGold));
@ -890,9 +906,9 @@ public class Mekanism
GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock");
GameRegistry.registerTileEntity(TileEntityControlPanel.class, "ControlPanel");
GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank");
GameRegistry.registerTileEntity(TileEntitySmeltingFactory.class, "SmeltingFactory");
GameRegistry.registerTileEntity(TileEntityAdvancedSmeltingFactory.class, "AdvancedSmeltingFactory");
GameRegistry.registerTileEntity(TileEntityEliteSmeltingFactory.class, "UltimateSmeltingFactory");
GameRegistry.registerTileEntity(TileEntityFactory.class, "SmeltingFactory");
GameRegistry.registerTileEntity(TileEntityAdvancedFactory.class, "AdvancedSmeltingFactory");
GameRegistry.registerTileEntity(TileEntityEliteFactory.class, "UltimateSmeltingFactory");
GameRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser");
GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter");
GameRegistry.registerTileEntity(TileEntityPurificationChamber.class, "PurificationChamber");

View file

@ -31,7 +31,6 @@ public final class MekanismHooks
private Class ForestryItem;
private Class Forestry;
public ItemStack IC2TinDust;
public ItemStack IC2CoalDust;
public int BuildCraftFuelID = 19108;
@ -61,7 +60,6 @@ public final class MekanismHooks
if(IC2Loaded)
{
IC2TinDust = getIC2Item("tinDust");
IC2CoalDust = getIC2Item("coalDust");
Ic2Recipes.addMaceratorRecipe(new ItemStack(Mekanism.OreBlock, 1, 0), new ItemStack(Mekanism.Dust, 2, 2));

View file

@ -16,11 +16,14 @@ import mekanism.api.EnumColor;
import mekanism.api.EnumGas;
import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IFactory;
import mekanism.api.IFactory.RecipeType;
import mekanism.api.IGasAcceptor;
import mekanism.api.IPressurizedTube;
import mekanism.api.ITubeConnection;
import mekanism.api.InfuseObject;
import mekanism.api.Tier.EnergyCubeTier;
import mekanism.api.Tier.FactoryTier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
@ -239,12 +242,19 @@ public final class MekanismUtils
* @param tier - tier to add to the Energy Cube
* @return empty energy cube with defined tier
*/
public static ItemStack getEnergyCubeWithTier(EnergyCubeTier tier)
public static ItemStack getEnergyCube(EnergyCubeTier tier)
{
ItemStack itemstack = ((ItemBlockEnergyCube)new ItemStack(Mekanism.EnergyCube).getItem()).getUnchargedItem(tier);
return itemstack;
}
public static ItemStack getFactory(FactoryTier tier, RecipeType type)
{
ItemStack itemstack = new ItemStack(Mekanism.MachineBlock, 1, 5+tier.ordinal());
((IFactory)itemstack.getItem()).setRecipeType(type.ordinal(), itemstack);
return itemstack;
}
/**
* Checks if a machine is in it's active state.
* @param world

View file

@ -2,13 +2,13 @@ package mekanism.common;
import mekanism.api.EnumColor;
import mekanism.api.SideData;
import mekanism.api.Tier.SmeltingFactoryTier;
import mekanism.api.Tier.FactoryTier;
public class TileEntityAdvancedSmeltingFactory extends TileEntitySmeltingFactory
public class TileEntityAdvancedFactory extends TileEntityFactory
{
public TileEntityAdvancedSmeltingFactory()
public TileEntityAdvancedFactory()
{
super(SmeltingFactoryTier.ADVANCED);
super(FactoryTier.ADVANCED);
sideOutputs.add(new SideData(EnumColor.GREY, 0, 0));
sideOutputs.add(new SideData(EnumColor.ORANGE, 0, 1));

View file

@ -7,6 +7,7 @@ import com.google.common.io.ByteArrayDataInput;
import ic2.api.IWrenchable;
import ic2.api.energy.EnergyNet;
import mekanism.api.ITileNetwork;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -141,6 +142,6 @@ public abstract class TileEntityBasicBlock extends TileEntityDisableable impleme
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
return new ItemStack(worldObj.getBlockId(xCoord, yCoord, zCoord), 1, worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
return Block.blocksList[getBlockType().blockID].getPickBlock(null, worldObj, xCoord, yCoord, zCoord);
}
}

View file

@ -12,9 +12,11 @@ import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IElectricMachine;
import mekanism.api.IEnergyCube;
import mekanism.api.IFactory;
import mekanism.api.IUpgradeManagement;
import mekanism.api.SideData;
import mekanism.client.Sound;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -407,15 +409,4 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp
{
speedMultiplier = multiplier;
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
ItemStack itemStack = new ItemStack(Mekanism.EnergyCube);
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
electricItem.setJoules(electricityStored, itemStack);
return itemStack;
}
}

View file

@ -174,8 +174,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
{
inventory[2] = itemstack;
}
else
{
else {
inventory[2].stackSize += itemstack.stackSize;
}
}
@ -204,8 +203,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine
{
return false;
}
else
{
else {
return inventory[2].stackSize + itemstack.stackSize <= inventory[2].getMaxStackSize();
}
}

View file

@ -2,13 +2,13 @@ package mekanism.common;
import mekanism.api.EnumColor;
import mekanism.api.SideData;
import mekanism.api.Tier.SmeltingFactoryTier;
import mekanism.api.Tier.FactoryTier;
public class TileEntityEliteSmeltingFactory extends TileEntitySmeltingFactory
public class TileEntityEliteFactory extends TileEntityFactory
{
public TileEntityEliteSmeltingFactory()
public TileEntityEliteFactory()
{
super(SmeltingFactoryTier.ELITE);
super(FactoryTier.ELITE);
sideOutputs.add(new SideData(EnumColor.GREY, 0, 0));
sideOutputs.add(new SideData(EnumColor.ORANGE, 0, 1));

View file

@ -412,18 +412,4 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements IEn
{
return (int)(tier.MAX_ELECTRICITY-electricityStored);
}
@Override
public ItemStack getWrenchDrop(EntityPlayer entityPlayer)
{
ItemStack itemStack = new ItemStack(Mekanism.EnergyCube);
IEnergyCube energyCube = (IEnergyCube)itemStack.getItem();
energyCube.setTier(itemStack, tier);
IItemElectric electricItem = (IItemElectric)itemStack.getItem();
electricItem.setJoules(electricityStored, itemStack);
return itemStack;
}
}

View file

@ -12,7 +12,8 @@ import mekanism.api.IActiveState;
import mekanism.api.IConfigurable;
import mekanism.api.IUpgradeManagement;
import mekanism.api.SideData;
import mekanism.api.Tier.SmeltingFactoryTier;
import mekanism.api.IFactory.RecipeType;
import mekanism.api.Tier.FactoryTier;
import mekanism.client.Sound;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -36,10 +37,10 @@ import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.IPeripheral;
public class TileEntitySmeltingFactory extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeManagement
public class TileEntityFactory extends TileEntityElectricBlock implements IEnergySink, IPeripheral, IActiveState, IConfigurable, IUpgradeManagement
{
/** This Smelting Factory's tier. */
public SmeltingFactoryTier tier;
public FactoryTier tier;
/** This machine's side configuration. */
public byte[] sideConfig;
@ -78,9 +79,12 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
/** This machine's active state. */
public boolean isActive;
public TileEntitySmeltingFactory()
/** This machine's recipe type. */
public int recipeType;
public TileEntityFactory()
{
this(SmeltingFactoryTier.BASIC);
this(FactoryTier.BASIC);
sideOutputs.add(new SideData(EnumColor.GREY, 0, 0));
sideOutputs.add(new SideData(EnumColor.ORANGE, 0, 1));
@ -91,9 +95,9 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
sideConfig = new byte[] {4, 3, 0, 0, 2, 1};
}
public TileEntitySmeltingFactory(SmeltingFactoryTier type)
public TileEntityFactory(FactoryTier type)
{
super(type.name + " Smelting Factory", type.processes*2000);
super(type.name + " Factory", type.processes*2000);
tier = type;
inventory = new ItemStack[2+type.processes*2];
progress = new int[type.processes];
@ -280,7 +284,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
if(FMLClientHandler.instance().getClient().sndManager.sndSystem != null)
{
audio = Mekanism.audioHandler.getSound("SmeltingFactory.ogg", worldObj, xCoord, yCoord, zCoord);
audio = Mekanism.audioHandler.getSound("Factory.ogg", worldObj, xCoord, yCoord, zCoord);
}
}
@ -342,7 +346,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
return false;
}
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[inputSlot]);
ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], false);
if (itemstack == null)
{
@ -358,8 +362,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
return false;
}
else
{
else {
return inventory[outputSlot].stackSize + itemstack.stackSize <= inventory[outputSlot].getMaxStackSize();
}
}
@ -371,9 +374,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
return;
}
ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[inputSlot]).copy();
inventory[inputSlot].stackSize--;
ItemStack itemstack = RecipeType.values()[recipeType].getCopiedOutput(inventory[inputSlot], true);
if (inventory[inputSlot].stackSize <= 0)
{
@ -384,8 +385,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
{
inventory[outputSlot] = itemstack;
}
else
{
else {
inventory[outputSlot].stackSize += itemstack.stackSize;
}
}
@ -409,6 +409,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
speedMultiplier = dataStream.readInt();
energyMultiplier = dataStream.readInt();
isActive = dataStream.readBoolean();
recipeType = dataStream.readInt();
for(int i = 0; i < tier.processes; i++)
{
@ -424,6 +425,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
speedMultiplier = nbtTags.getInteger("speedMultiplier");
energyMultiplier = nbtTags.getInteger("energyMultiplier");
isActive = nbtTags.getBoolean("isActive");
recipeType = nbtTags.getInteger("recipeType");
for(int i = 0; i < tier.processes; i++)
{
@ -447,6 +449,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
nbtTags.setInteger("speedMultiplier", speedMultiplier);
nbtTags.setInteger("energyMultiplier", energyMultiplier);
nbtTags.setBoolean("isActive", isActive);
nbtTags.setInteger("recipeType", recipeType);
for(int i = 0; i < tier.processes; i++)
{
@ -468,6 +471,7 @@ public class TileEntitySmeltingFactory extends TileEntityElectricBlock implement
data.add(speedMultiplier);
data.add(energyMultiplier);
data.add(isActive);
data.add(recipeType);
data.add(progress);
return data;
}

View file

@ -37,7 +37,7 @@ public class GeneratorsCommonProxy
public void loadConfiguration()
{
Mekanism.configuration.load();
MekanismGenerators.generatorID = Mekanism.configuration.getBlock("Generator", 3005).getInt();
MekanismGenerators.generatorID = Mekanism.configuration.getBlock("Generator", 3010).getInt();
Mekanism.configuration.save();
}

View file

@ -40,7 +40,7 @@ public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler
@Override
public String getGuiTexture()
{
return "/resources/mekanism/gui/GuiCombiner.png";
return "/mods/mekanism/gui/GuiCombiner.png";
}
@Override

View file

@ -36,7 +36,7 @@ public class CrusherRecipeHandler extends MachineRecipeHandler
@Override
public String getGuiTexture()
{
return "/resources/mekanism/gui/GuiCrusher.png";
return "/mods/mekanism/gui/GuiCrusher.png";
}
@Override

View file

@ -36,7 +36,7 @@ public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler
@Override
public String getGuiTexture()
{
return "/resources/mekanism/gui/GuiChamber.png";
return "/mods/mekanism/gui/GuiChamber.png";
}
@Override

View file

@ -0,0 +1,164 @@
package mekanism.nei;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import mekanism.api.IFactory;
import mekanism.common.FactoryRecipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import codechicken.core.ReflectionManager;
import codechicken.nei.NEICompatibility;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.ShapedRecipeHandler;
import codechicken.nei.recipe.weakDependancy_Forge;
import codechicken.nei.recipe.ShapedRecipeHandler.CachedShapedRecipe;
import codechicken.nei.recipe.TemplateRecipeHandler.CachedRecipe;
public class FactoryRecipeHandler extends ShapedRecipeHandler
{
@Override
public String getRecipeName()
{
return "Shaped Factory Crafting";
}
@Override
public void loadCraftingRecipes(String outputId, Object... results)
{
if(outputId.equals("crafting") && getClass() == FactoryRecipeHandler.class)
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for(IRecipe irecipe : allrecipes)
{
if(irecipe instanceof FactoryRecipe)
{
FactoryRecipe factoryRecipe = (FactoryRecipe)irecipe;
CachedFactoryRecipe recipe = new CachedFactoryRecipe(3, 3, factoryRecipe.getInput(), factoryRecipe.getRecipeOutput());
arecipes.add(recipe);
}
}
}
else
{
super.loadCraftingRecipes(outputId, results);
}
}
@Override
public void loadCraftingRecipes(ItemStack result)
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for(IRecipe irecipe : allrecipes)
{
if(irecipe instanceof FactoryRecipe && areFactoriesEqual(irecipe.getRecipeOutput(), result))
{
FactoryRecipe factoryRecipe = (FactoryRecipe)irecipe;
CachedFactoryRecipe recipe = new CachedFactoryRecipe(3, 3, factoryRecipe.getInput(), factoryRecipe.getRecipeOutput());
arecipes.add(recipe);
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient)
{
List<IRecipe> allrecipes = CraftingManager.getInstance().getRecipeList();
for(IRecipe irecipe : allrecipes)
{
if(irecipe instanceof FactoryRecipe)
{
FactoryRecipe factoryRecipe = (FactoryRecipe)irecipe;
CachedFactoryRecipe recipe = new CachedFactoryRecipe(3, 3, factoryRecipe.getInput(), factoryRecipe.getRecipeOutput());
if(recipe.contains(recipe.ingredients, ingredient))
{
recipe.setIngredientPermutation(recipe.ingredients, ingredient);
arecipes.add(recipe);
}
}
}
}
public static boolean areFactoriesEqual(ItemStack stack1, ItemStack stack2)
{
if(stack1 == null || stack2 == null)
{
return false;
}
if(stack1.itemID != stack2.itemID || stack1.getItemDamage() != stack2.getItemDamage())
{
return false;
}
if(stack1.getItem() instanceof IFactory && stack2.getItem() instanceof IFactory)
{
if(((IFactory)stack1.getItem()).getRecipeType(stack1) != ((IFactory)stack2.getItem()).getRecipeType(stack2))
{
return false;
}
}
return true;
}
public class CachedFactoryRecipe extends CachedRecipe
{
public ArrayList<PositionedStack> ingredients;
public PositionedStack result;
public CachedFactoryRecipe(int width, int height, Object[] items, ItemStack out)
{
result = new PositionedStack(out, 119, 24);
ingredients = new ArrayList<PositionedStack>();
setIngredients(width, height, items);
}
public void setIngredients(int width, int height, Object[] items)
{
for(int x = 0; x < width; x++)
{
for(int y = 0; y < height; y++)
{
if(items[y*width+x] == null)
{
continue;
}
PositionedStack stack = new PositionedStack(items[y*width+x], 25+x*18, 6+y*18);
stack.setMaxSize(1);
ingredients.add(stack);
}
}
}
@Override
public ArrayList<PositionedStack> getIngredients()
{
return getCycledIngredients(FactoryRecipeHandler.this.cycleticks / 20, ingredients);
}
@Override
public PositionedStack getResult()
{
return result;
}
@Override
public boolean contains(Collection<PositionedStack> ingredients, ItemStack ingredient)
{
for(PositionedStack stack : ingredients)
{
for(ItemStack item : stack.items)
{
if(areFactoriesEqual(item, ingredient))
return true;
}
}
return false;
}
}
}

View file

@ -44,7 +44,7 @@ public class MetallurgicInfuserRecipeHandler extends TemplateRecipeHandler
@Override
public String getGuiTexture()
{
return "/resources/mekanism/gui/GuiMetallurgicInfuser.png";
return "/mods/mekanism/gui/GuiMetallurgicInfuser.png";
}
@Override

View file

@ -21,6 +21,8 @@ public class NEIMekanismConfig implements IConfigureNEI
API.registerUsageHandler(new MetallurgicInfuserRecipeHandler());
API.registerRecipeHandler(new PurificationChamberRecipeHandler());
API.registerUsageHandler(new PurificationChamberRecipeHandler());
API.registerRecipeHandler(new FactoryRecipeHandler());
API.registerUsageHandler(new FactoryRecipeHandler());
API.hideItem(Mekanism.boundingBlockID);
}

View file

@ -39,7 +39,7 @@ public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler
@Override
public String getGuiTexture()
{
return "/resources/mekanism/gui/GuiCompressor.png";
return "/mods/mekanism/gui/GuiCompressor.png";
}
@Override

View file

@ -38,7 +38,7 @@ public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandl
@Override
public String getGuiTexture()
{
return "/resources/mekanism/gui/GuiPurificationChamber.png";
return "/mods/mekanism/gui/GuiPurificationChamber.png";
}
@Override