Work on recipes, fixed a few bugs

This commit is contained in:
Aidan Brady 2014-01-13 21:43:36 -05:00
parent 0aafa16106
commit 8f6b618328
5 changed files with 168 additions and 3 deletions

View file

@ -10,6 +10,7 @@ import mekanism.api.Coord4D;
import mekanism.common.tank.DynamicTankCache; import mekanism.common.tank.DynamicTankCache;
import mekanism.common.tile.TileEntityDynamicTank; import mekanism.common.tile.TileEntityDynamicTank;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType; import cpw.mods.fml.common.TickType;
@ -39,9 +40,9 @@ public class CommonWorldTickHandler implements ITickHandler
{ {
if(obj.dimensionId == world.provider.dimensionId) if(obj.dimensionId == world.provider.dimensionId)
{ {
TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)obj.getTileEntity(world); TileEntity tileEntity = obj.getTileEntity(world);
if(tileEntity == null || tileEntity.inventoryID != inventoryID) if(!(tileEntity instanceof TileEntityDynamicTank) || ((TileEntityDynamicTank)tileEntity).inventoryID != inventoryID)
{ {
if(!tilesToKill.containsKey(inventoryID)) if(!tilesToKill.containsKey(inventoryID))
{ {

View file

@ -518,6 +518,15 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(ElectrolyticCore), new Object[] { CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(ElectrolyticCore), new Object[] {
"EPE", "IEG", "EPE", Character.valueOf('E'), Mekanism.EnrichedAlloy, Character.valueOf('P'), "dustOsmium", Character.valueOf('I'), "dustIron", Character.valueOf('G'), "dustGold" "EPE", "IEG", "EPE", Character.valueOf('E'), Mekanism.EnrichedAlloy, Character.valueOf('P'), "dustOsmium", Character.valueOf('I'), "dustIron", Character.valueOf('G'), "dustGold"
})); }));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(CardboardBox), new Object[] {
"SSS", "S S" , "SSS", Character.valueOf('S'), Sawdust
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Item.paper, 6), new Object[] {
"SSS", Character.valueOf('S'), Sawdust
}));
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(MachineBlock2, 1, 5), new Object[] {
"ICI", "ASA", "ICI", Character.valueOf('I'), "ingotIron", Character.valueOf('C'), "circuitBasic", Character.valueOf('A'), EnrichedAlloy, Character.valueOf('S'), new ItemStack(BasicBlock, 1, 8)
}));
for(RecipeType type : RecipeType.values()) for(RecipeType type : RecipeType.values())
{ {
@ -650,6 +659,14 @@ public class Mekanism
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.trapdoor), new ChanceOutput(new ItemStack(Block.planks, 3))); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.trapdoor), new ChanceOutput(new ItemStack(Block.planks, 3)));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Item.boat), new ChanceOutput(new ItemStack(Block.planks, 5))); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Item.boat), new ChanceOutput(new ItemStack(Block.planks, 5)));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Item.bed), new ChanceOutput(new ItemStack(Block.planks, 3), new ItemStack(Block.cloth, 3), 1)); RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Item.bed), new ChanceOutput(new ItemStack(Block.planks, 3), new ItemStack(Block.cloth, 3), 1));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.jukebox), new ChanceOutput(new ItemStack(Block.planks, 8), new ItemStack(Item.diamond), 1));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.bookShelf), new ChanceOutput(new ItemStack(Block.planks, 6), new ItemStack(Item.book, 3), 1));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.pressurePlatePlanks), new ChanceOutput(new ItemStack(Block.planks, 2)));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.fence), new ChanceOutput(new ItemStack(Item.stick, 3)));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.fenceGate), new ChanceOutput(new ItemStack(Block.planks, 2), new ItemStack(Item.stick, 4), 1));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.music), new ChanceOutput(new ItemStack(Block.planks, 8), new ItemStack(Item.redstone, 1), 1));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.torchRedstoneIdle), new ChanceOutput(new ItemStack(Item.stick, 1), new ItemStack(Item.redstone), 1));
RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Block.workbench), new ChanceOutput(new ItemStack(Block.planks, 4)));
//Metallurgic Infuser Recipes //Metallurgic Infuser Recipes
RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(Item.ingotIron)), new ItemStack(EnrichedIron)); RecipeHandler.addMetallurgicInfuserRecipe(InfusionInput.getInfusion(InfuseRegistry.get("CARBON"), 10, new ItemStack(Item.ingotIron)), new ItemStack(EnrichedIron));

View file

@ -5,6 +5,7 @@ import java.util.Random;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.item.ItemBlockCardboardBox; import mekanism.common.item.ItemBlockCardboardBox;
import mekanism.common.tile.TileEntityCardboardBox; import mekanism.common.tile.TileEntityCardboardBox;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer; import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.client.renderer.texture.IconRegister;
@ -54,7 +55,7 @@ public class BlockCardboardBox extends BlockContainer
} }
@Override @Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float hitX, float hitY, float hitZ)
{ {
if(!world.isRemote && entityplayer.isSneaking()) if(!world.isRemote && entityplayer.isSneaking())
{ {
@ -64,6 +65,12 @@ public class BlockCardboardBox extends BlockContainer
if(tileEntity.storedData != null) if(tileEntity.storedData != null)
{ {
BlockData data = tileEntity.storedData; BlockData data = tileEntity.storedData;
if(Block.blocksList[data.id] != null)
{
data.meta = Block.blocksList[data.id].onBlockPlaced(world, x, y, z, facing, hitX, hitY, hitZ, data.meta);
}
world.setBlock(x, y, z, data.id, data.meta, 3); world.setBlock(x, y, z, data.id, data.meta, 3);
if(data.tileTag != null && world.getBlockTileEntity(x, y, z) != null) if(data.tileTag != null && world.getBlockTileEntity(x, y, z) != null)
@ -72,6 +79,12 @@ public class BlockCardboardBox extends BlockContainer
world.getBlockTileEntity(x, y, z).readFromNBT(data.tileTag); world.getBlockTileEntity(x, y, z).readFromNBT(data.tileTag);
} }
if(Block.blocksList[data.id] != null)
{
Block.blocksList[data.id].onBlockPlacedBy(world, x, y, z, entityplayer, new ItemStack(data.id, 1, data.meta));
Block.blocksList[data.id].onPostBlockPlaced(world, x, y, z, data.meta);
}
float motion = 0.7F; float motion = 0.7F;
double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;
double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D;

View file

@ -2,15 +2,25 @@ package mekanism.common.integration;
import ic2.api.recipe.RecipeInputOreDict; import ic2.api.recipe.RecipeInputOreDict;
import ic2.api.recipe.Recipes; import ic2.api.recipe.Recipes;
import java.util.ArrayList;
import mekanism.api.ChanceOutput;
import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseObject;
import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseRegistry;
import mekanism.api.infuse.InfusionInput; import mekanism.api.infuse.InfusionInput;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.StackUtils;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
@ -18,6 +28,24 @@ public final class OreDictManager
{ {
public static void init() public static void init()
{ {
addLogRecipes();
for(ItemStack ore : OreDictionary.getOres("plankWood"))
{
if(ore.getHasSubtypes())
{
ItemStack wildStack = new ItemStack(ore.itemID, 1, OreDictionary.WILDCARD_VALUE);
if(!Recipe.PRECISION_SAWMILL.containsRecipe(wildStack))
{
RecipeHandler.addPrecisionSawmillRecipe(wildStack, new ChanceOutput(new ItemStack(Item.stick, 6), new ItemStack(Mekanism.Sawdust), 0.25));
}
}
else {
RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(ore, 1), new ChanceOutput(new ItemStack(Item.stick, 6), new ItemStack(Mekanism.Sawdust), 0.25));
}
}
for(ItemStack ore : OreDictionary.getOres("dustRefinedObsidian")) for(ItemStack ore : OreDictionary.getOres("dustRefinedObsidian"))
{ {
RecipeHandler.addOsmiumCompressorRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Ingot, 1, 0)); RecipeHandler.addOsmiumCompressorRecipe(MekanismUtils.size(ore, 1), new ItemStack(Mekanism.Ingot, 1, 0));
@ -367,4 +395,57 @@ public final class OreDictManager
} }
} catch(Exception e) {} } catch(Exception e) {}
} }
/**
* Handy method for retrieving all log items, finding their corresponding planks, and making recipes with them. Taken from CofhCore.
*/
public static void addLogRecipes()
{
Container tempContainer = new Container() {
public boolean canInteractWith(EntityPlayer player)
{
return false;
}
};
InventoryCrafting tempCrafting = new InventoryCrafting(tempContainer, 3, 3);
ArrayList recipeList = (ArrayList)CraftingManager.getInstance().getRecipeList();
for(int i = 1; i < 9; i++)
{
tempCrafting.setInventorySlotContents(i, null);
}
ArrayList registeredOres = OreDictionary.getOres("logWood");
for(int i = 0; i < registeredOres.size(); i++)
{
ItemStack logEntry = (ItemStack)registeredOres.get(i);
if(logEntry.getItemDamage() == OreDictionary.WILDCARD_VALUE)
{
for(int j = 0; j < 16; j++)
{
ItemStack log = new ItemStack(logEntry.itemID, 1, j);
tempCrafting.setInventorySlotContents(0, log);
ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null);
if(resultEntry != null)
{
RecipeHandler.addPrecisionSawmillRecipe(log, new ChanceOutput(StackUtils.size(resultEntry, 6), new ItemStack(Mekanism.Sawdust), 1));
}
}
}
else {
ItemStack log = StackUtils.size(logEntry, 1);
tempCrafting.setInventorySlotContents(0, log);
ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null);
if(resultEntry != null)
{
RecipeHandler.addPrecisionSawmillRecipe(log, new ChanceOutput(StackUtils.size(resultEntry, 6), new ItemStack(Mekanism.Sawdust), 1));
}
}
}
}
} }

View file

@ -48,6 +48,8 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
@ -1213,6 +1215,57 @@ public final class MekanismUtils
return tank; return tank;
} }
/**
* Finds the output of a defined InventoryCrafting grid. Taken from CofhCore.
* @param inv - InventoryCrafting to check
* @param world - world reference
* @return output ItemStack
*/
public static ItemStack findMatchingRecipe(InventoryCrafting inv, World world)
{
ItemStack[] dmgItems = new ItemStack[2];
for(int i = 0; i < inv.getSizeInventory(); i++)
{
if(inv.getStackInSlot(i) != null)
{
if(dmgItems[0] == null)
{
dmgItems[0] = inv.getStackInSlot(i);
}
else {
dmgItems[1] = inv.getStackInSlot(i);
break;
}
}
}
if((dmgItems[0] == null) || (Item.itemsList[dmgItems[0].itemID] == null))
{
return null;
}
if((dmgItems[1] != null) && (dmgItems[0].itemID == dmgItems[1].itemID) && (dmgItems[0].stackSize == 1) && (dmgItems[1].stackSize == 1) && (Item.itemsList[dmgItems[0].itemID].isRepairable()))
{
Item theItem = Item.itemsList[dmgItems[0].itemID];
int dmgDiff0 = theItem.getMaxDamage() - dmgItems[0].getItemDamageForDisplay();
int dmgDiff1 = theItem.getMaxDamage() - dmgItems[1].getItemDamageForDisplay();
int value = dmgDiff0 + dmgDiff1 + theItem.getMaxDamage() * 5 / 100;
int solve = Math.max(0, theItem.getMaxDamage() - value);
return new ItemStack(dmgItems[0].itemID, 1, solve);
}
for(IRecipe recipe : (List<IRecipe>)CraftingManager.getInstance().getRecipeList())
{
if(recipe.matches(inv, world))
{
return recipe.getCraftingResult(inv);
}
}
return null;
}
public static enum ResourceType public static enum ResourceType
{ {
GUI("gui"), GUI("gui"),