reworking the casting classes
This commit is contained in:
@@ -54,22 +54,6 @@ public class CastingForm extends CustomContainerFacing implements CastingFormHan
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTick(World world, BlockPos pos, IBlockState state, Random random)
|
|
||||||
{
|
|
||||||
if (!world.isRemote) {
|
|
||||||
if(randomCheck(4)) {
|
|
||||||
TileCastingForm tile = (TileCastingForm) world.getTileEntity(pos);
|
|
||||||
String[] tempArray = new String[25];
|
|
||||||
for (int i = 0; i < 25; i++) {
|
|
||||||
tempArray[i] = tile.getSlotStack(i).getItem().getRegistryName().toString();
|
|
||||||
}
|
|
||||||
doCraftingformCrafting(tempArray, world, tile, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
public void breakBlock(World world, BlockPos pos, IBlockState state)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package nmd.primal.forgecraft.crafting;
|
package nmd.primal.forgecraft.crafting;
|
||||||
|
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -8,19 +9,19 @@ import java.util.Arrays;
|
|||||||
/**
|
/**
|
||||||
* Created by mminaie on 6/22/17.
|
* Created by mminaie on 6/22/17.
|
||||||
*/
|
*/
|
||||||
public class CastingformCrafting {
|
public class CastingCrafting {
|
||||||
|
|
||||||
// ***************************************************************************** //
|
// ***************************************************************************** //
|
||||||
// Recipe Handler AnvilCrafting
|
// Recipe Handler AnvilCrafting
|
||||||
// ***************************************************************************** //
|
// ***************************************************************************** //
|
||||||
|
|
||||||
private static ArrayList<CastingformCrafting> castingRecipes = new ArrayList<>();
|
private static ArrayList<CastingCrafting> castingRecipes = new ArrayList<>();
|
||||||
|
|
||||||
private String[] input = new String[25];
|
private Item[] input = new Item[25];
|
||||||
|
|
||||||
private ItemStack output;
|
private ItemStack output;
|
||||||
|
|
||||||
public CastingformCrafting(String[] input, ItemStack output){
|
public CastingCrafting(Item[] input, ItemStack output){
|
||||||
|
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.output = output;
|
this.output = output;
|
||||||
@@ -31,14 +32,14 @@ public class CastingformCrafting {
|
|||||||
// Recipe Methods
|
// Recipe Methods
|
||||||
// ***************************************************************************** //
|
// ***************************************************************************** //
|
||||||
|
|
||||||
public static void addRecipe(String[] input, ItemStack output)
|
public static void addRecipe(Item[] input, ItemStack output)
|
||||||
{
|
{
|
||||||
castingRecipes.add(new CastingformCrafting(input, output));
|
castingRecipes.add(new CastingCrafting(input, output));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRecipe(String[] array)
|
public static boolean isRecipe(Item[] array)
|
||||||
{
|
{
|
||||||
for(CastingformCrafting recipe : castingRecipes) {
|
for(CastingCrafting recipe : castingRecipes) {
|
||||||
if (Arrays.equals(array, recipe.input))
|
if (Arrays.equals(array, recipe.input))
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -46,16 +47,16 @@ public class CastingformCrafting {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CastingformCrafting getRecipe(String[] array)
|
public static CastingCrafting getRecipe(Item[] array)
|
||||||
{
|
{
|
||||||
for(CastingformCrafting recipe : castingRecipes) {
|
for(CastingCrafting recipe : castingRecipes) {
|
||||||
if (Arrays.equals(array, recipe.input))
|
if (Arrays.equals(array, recipe.input))
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getInput() {return this.input;}
|
public Item[] getInput() {return this.input;}
|
||||||
|
|
||||||
public ItemStack getOutput() {return this.output;}
|
public ItemStack getOutput() {return this.output;}
|
||||||
|
|
||||||
@@ -3,7 +3,6 @@ package nmd.primal.forgecraft.init;
|
|||||||
import net.minecraft.block.BlockPlanks;
|
import net.minecraft.block.BlockPlanks;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.init.Items;
|
import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.EnumDyeColor;
|
|
||||||
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.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
@@ -13,7 +12,7 @@ import net.minecraftforge.oredict.OreIngredient;
|
|||||||
import nmd.primal.core.api.PrimalAPI;
|
import nmd.primal.core.api.PrimalAPI;
|
||||||
import nmd.primal.core.common.recipes.irecipe.RecipeHandler;
|
import nmd.primal.core.common.recipes.irecipe.RecipeHandler;
|
||||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||||
import nmd.primal.forgecraft.crafting.CastingformCrafting;
|
import nmd.primal.forgecraft.crafting.CastingCrafting;
|
||||||
import nmd.primal.forgecraft.crafting.CrucibleCrafting;
|
import nmd.primal.forgecraft.crafting.CrucibleCrafting;
|
||||||
import nmd.primal.forgecraft.crafting.ForgeCrafting;
|
import nmd.primal.forgecraft.crafting.ForgeCrafting;
|
||||||
|
|
||||||
@@ -722,62 +721,62 @@ public class ModCrafting{
|
|||||||
CASTING
|
CASTING
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
String empty = ItemStack.EMPTY.getItem().getRegistryName().toString();
|
Item empty = Items.AIR;
|
||||||
String muddd = ModItems.castingmud.getRegistryName().toString();
|
Item muddd = ModItems.castingmud;
|
||||||
|
|
||||||
//Casting Pickaxe
|
//Casting Pickaxe
|
||||||
CastingformCrafting.addRecipe(
|
CastingCrafting.addRecipe(
|
||||||
new String[] {
|
new Item[] {
|
||||||
muddd,muddd,muddd,muddd,muddd,
|
muddd,muddd,muddd,muddd,muddd,
|
||||||
muddd,empty,empty,empty,muddd,
|
muddd,empty,empty,empty,muddd,
|
||||||
empty,muddd,muddd,muddd,empty,
|
empty,muddd,muddd,muddd,empty,
|
||||||
muddd,muddd,muddd,muddd,muddd,
|
muddd,muddd,muddd,muddd,muddd,
|
||||||
muddd,muddd,muddd,muddd,muddd },
|
muddd,muddd,muddd,muddd,muddd },
|
||||||
new ItemStack(ModItems.cast_pickaxe, 1)
|
new ItemStack(ModItems.bronzepickaxehead, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
//Casting Shovel
|
//Casting Shovel
|
||||||
CastingformCrafting.addRecipe(
|
CastingCrafting.addRecipe(
|
||||||
new String[] {
|
new Item[] {
|
||||||
muddd,muddd,muddd,muddd,muddd,
|
muddd,muddd,muddd,muddd,muddd,
|
||||||
muddd,muddd,empty,muddd,muddd,
|
muddd,muddd,empty,muddd,muddd,
|
||||||
muddd,empty,empty,empty,muddd,
|
muddd,empty,empty,empty,muddd,
|
||||||
muddd,empty,empty,empty,muddd,
|
muddd,empty,empty,empty,muddd,
|
||||||
muddd,empty,muddd,empty,muddd },
|
muddd,empty,muddd,empty,muddd },
|
||||||
new ItemStack(ModItems.cast_shovel, 1)
|
new ItemStack(ModItems.bronzeshovelhead, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
//Casting Axe
|
//Casting Axe
|
||||||
CastingformCrafting.addRecipe(
|
CastingCrafting.addRecipe(
|
||||||
new String[] {
|
new Item[] {
|
||||||
muddd,empty,empty,muddd,muddd,
|
muddd,empty,empty,muddd,muddd,
|
||||||
muddd,empty,empty,empty,muddd,
|
muddd,empty,empty,empty,muddd,
|
||||||
muddd,empty,empty,empty,muddd,
|
muddd,empty,empty,empty,muddd,
|
||||||
muddd,empty,muddd,muddd,muddd,
|
muddd,empty,muddd,muddd,muddd,
|
||||||
muddd,muddd,muddd,muddd,muddd },
|
muddd,muddd,muddd,muddd,muddd },
|
||||||
new ItemStack(ModItems.cast_axe, 1)
|
new ItemStack(ModItems.bronzeaxehead, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
//Casting Hoe
|
//Casting Hoe
|
||||||
CastingformCrafting.addRecipe(
|
CastingCrafting.addRecipe(
|
||||||
new String[] {
|
new Item[] {
|
||||||
muddd,muddd,muddd,empty,empty,
|
muddd,muddd,muddd,empty,empty,
|
||||||
muddd,muddd,empty,muddd,muddd,
|
muddd,muddd,empty,muddd,muddd,
|
||||||
muddd,empty,muddd,muddd,muddd,
|
muddd,empty,muddd,muddd,muddd,
|
||||||
empty,muddd,muddd,muddd,muddd,
|
empty,muddd,muddd,muddd,muddd,
|
||||||
muddd,muddd,muddd,muddd,muddd },
|
muddd,muddd,muddd,muddd,muddd },
|
||||||
new ItemStack(ModItems.cast_hoe, 1)
|
new ItemStack(ModItems.bronzehoehead, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
//Casting Gladius
|
//Casting Gladius
|
||||||
CastingformCrafting.addRecipe(
|
CastingCrafting.addRecipe(
|
||||||
new String[] {
|
new Item[] {
|
||||||
muddd,muddd,muddd,muddd,muddd,
|
muddd,muddd,muddd,muddd,muddd,
|
||||||
muddd,muddd,empty,muddd,muddd,
|
muddd,muddd,empty,muddd,muddd,
|
||||||
muddd,muddd,empty,muddd,muddd,
|
muddd,muddd,empty,muddd,muddd,
|
||||||
muddd,empty,empty,empty,muddd,
|
muddd,empty,empty,empty,muddd,
|
||||||
muddd,muddd,empty,muddd,muddd },
|
muddd,muddd,empty,muddd,muddd },
|
||||||
new ItemStack(ModItems.cast_gladius, 1)
|
new ItemStack(ModItems.bronzegladius, 1)
|
||||||
);
|
);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ package nmd.primal.forgecraft.util;
|
|||||||
|
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import nmd.primal.core.common.helper.PlayerHelper;
|
import nmd.primal.core.common.helper.PlayerHelper;
|
||||||
import nmd.primal.forgecraft.CommonUtils;
|
import nmd.primal.forgecraft.CommonUtils;
|
||||||
import nmd.primal.forgecraft.crafting.CastingformCrafting;
|
import nmd.primal.forgecraft.crafting.CastingCrafting;
|
||||||
import nmd.primal.forgecraft.init.ModItems;
|
import nmd.primal.forgecraft.init.ModItems;
|
||||||
import nmd.primal.forgecraft.tiles.TileCastingForm;
|
import nmd.primal.forgecraft.tiles.TileCastingForm;
|
||||||
|
|
||||||
@@ -188,8 +189,8 @@ public interface CastingFormHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
default void doCraftingformCrafting(String[] tempArray, World world, TileCastingForm tile, BlockPos pos){
|
default void doCraftingformCrafting(Item[] tempArray, World world, TileCastingForm tile, BlockPos pos){
|
||||||
CastingformCrafting recipe = CastingformCrafting.getRecipe(tempArray);
|
CastingCrafting recipe = CastingCrafting.getRecipe(tempArray);
|
||||||
if (recipe != null) {
|
if (recipe != null) {
|
||||||
CommonUtils.spawnItemEntityFromWorld(world, pos, recipe.getOutput());
|
CommonUtils.spawnItemEntityFromWorld(world, pos, recipe.getOutput());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user