working on forging recipe handler

This commit is contained in:
Mohammad-Ali Minaie
2017-02-24 17:59:50 -05:00
parent 5264b0c341
commit a881787ade
2 changed files with 48 additions and 27 deletions

View File

@@ -1,5 +1,7 @@
package nmd.primal.forgecraft.crafting;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
@@ -14,21 +16,24 @@ public class ForgeCrafting {
// ***************************************************************************** //
private static ArrayList<ForgeCrafting> forgeRecipes = new ArrayList<>();
private ItemStack input;
private ItemStack output;
private Block input;
private IBlockState start_state;
private IBlockState end_state;
private ItemStack output_failed;
private ItemStack cool_output;
private IBlockState cool_state;
private int heat_threshold;
private int ideal_time;
private int cooldown;
public ForgeCrafting(ItemStack input, ItemStack output, ItemStack output_failed, ItemStack cool_output, int heat_threshold, int ideal_time, int cooldown,float heat_variance, float time_variance)
public ForgeCrafting(Block input, IBlockState startState, IBlockState endState, ItemStack output_failed, IBlockState coolState, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance)
{
this.input = input;
this.output = output;
this.start_state = startState;
this.end_state = endState;
this.output_failed = output_failed;
this.cool_output = cool_output;
this.cool_state = coolState;
this.heat_threshold = heat_threshold;
this.ideal_time = ideal_time;
this.cooldown = cooldown;
@@ -38,64 +43,64 @@ public class ForgeCrafting {
// ***************************************************************************** //
// Recipe Methods
// ***************************************************************************** //
public static void addRecipe(ItemStack input, ItemStack output, ItemStack failed, ItemStack cool, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance)
public static void addRecipe(Block input, IBlockState startState, IBlockState endState, ItemStack output_failed, IBlockState coolState, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance)
{
forgeRecipes.add(new ForgeCrafting(input, output, failed, cool, heat_threshold, ideal_time, cooldown, heat_variance, time_variance));
forgeRecipes.add(new ForgeCrafting(input, startState, endState, output_failed, coolState, heat_threshold, ideal_time, cooldown, heat_variance, time_variance));
}
public static boolean isRecipeItem(ItemStack stack)
public static boolean isRecipeItem(Block block)
{
for(ForgeCrafting recipe : forgeRecipes) {
if (stack.isItemEqual(recipe.input))
if (block.equals(recipe.input))
return true;
}
return false;
}
public static boolean isOutputItem(ItemStack stack)
public static boolean isOutputState(IBlockState state)
{
for(ForgeCrafting recipe : forgeRecipes) {
if (stack.isItemEqual(recipe.output))
if (state.equals(recipe.end_state))
return true;
}
return false;
}
public static boolean isCoolItem(ItemStack stack)
public static boolean isCoolState(IBlockState coolState)
{
for(ForgeCrafting recipe : forgeRecipes) {
if (stack.isItemEqual(recipe.cool_output))
if (coolState.equals(recipe.cool_state))
return true;
}
return false;
}
public static ForgeCrafting getRecipe(ItemStack stack)
public static ForgeCrafting getRecipe(Block block)
{
for(ForgeCrafting recipe : forgeRecipes) {
if (stack.isItemEqual(recipe.input))
if (block.equals(recipe.input))
return recipe;
}
return null;
}
public static ForgeCrafting getRecipeFromOutput(ItemStack stack)
public static ForgeCrafting getRecipeFromOutput(Block block, IBlockState state)
{
for(ForgeCrafting recipe : forgeRecipes) {
if (stack.isItemEqual(recipe.output))
if (block.equals(recipe.input) && state.equals(recipe.end_state))
return recipe;
}
return null;
}
public ItemStack getInput()
public Block getInput()
{
return this.input;
}
public ItemStack getOutput()
public IBlockState getOutput()
{
return this.output;
return this.end_state;
}
public ItemStack getOutputFailed()
@@ -103,9 +108,9 @@ public class ForgeCrafting {
return this.output_failed;
}
public ItemStack getCoolOutput()
public IBlockState getCoolOutput()
{
return this.cool_output;
return this.cool_state;
}
public int getHeatThreshold()

View File

@@ -1,12 +1,16 @@
package nmd.primal.forgecraft.init;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nmd.primal.forgecraft.blocks.Bloomery;
import nmd.primal.forgecraft.blocks.IngotBall;
import nmd.primal.forgecraft.crafting.BloomeryCrafting;
import nmd.primal.forgecraft.crafting.ForgeCrafting;
/**
* Created by kitsu on 11/30/2016.
@@ -15,7 +19,8 @@ public class ModCrafting {
public static void register() {
/***Forge***/
GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.firebox), "X X", "XYX", "X X", 'X', Items.BRICK, 'Y', Blocks.FURNACE);
GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.firebox),
"X X", "XYX", "X X", 'X', Items.BRICK, 'Y', Blocks.FURNACE);
/***Wooden PistonBellows***/
GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.pistonbellowsoak), "XXX", "X Y", "XXX",
@@ -32,13 +37,16 @@ public class ModCrafting {
'X', new ItemStack(Blocks.PLANKS, 1, 5), 'Y', ModItems.pistonbellows);
/***Bellows Handle***/
GameRegistry.addShapedRecipe(new ItemStack(ModItems.pistonbellows), "X X", "X X", " X ", 'X', Items.STICK);
GameRegistry.addShapedRecipe(new ItemStack(ModItems.pistonbellows),
"X X", "X X", " X ", 'X', Items.STICK);
/***Tongs***/
GameRegistry.addShapedRecipe(new ItemStack(ModItems.stonetongs, 1), "X X", "YSY", 'X', Blocks.STONE, 'S', Items.STRING, 'Y', Items.STICK);
GameRegistry.addShapedRecipe(new ItemStack(ModItems.stonetongs, 1),
"X X", "YSY", 'X', Blocks.STONE, 'S', Items.STRING, 'Y', Items.STICK);
/***Iron Crucible***/
GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.rawironcrucible, 1), " X ", " Y ", 'X', Blocks.IRON_ORE, 'Y', ModBlocks.emptycrucible);
GameRegistry.addShapedRecipe(new ItemStack(ModBlocks.rawironcrucible, 1),
" X ", " Y ", 'X', Blocks.IRON_ORE, 'Y', ModBlocks.emptycrucible);
/***Bloomery Crafting***/
@@ -105,5 +113,13 @@ public class ModCrafting {
0.5f
);
//Makes a Hot Iron Ingot
ForgeCrafting.addRecipe(
ModBlocks.ironball,
);
}
}