intial crafting system in place for the anvil
This commit is contained in:
@@ -21,6 +21,7 @@ import nmd.primal.core.api.PrimalBlocks;
|
|||||||
import nmd.primal.core.api.PrimalItems;
|
import nmd.primal.core.api.PrimalItems;
|
||||||
import nmd.primal.forgecraft.CommonUtils;
|
import nmd.primal.forgecraft.CommonUtils;
|
||||||
import nmd.primal.forgecraft.ModInfo;
|
import nmd.primal.forgecraft.ModInfo;
|
||||||
|
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||||
import nmd.primal.forgecraft.init.ModItems;
|
import nmd.primal.forgecraft.init.ModItems;
|
||||||
import nmd.primal.forgecraft.tiles.TileAnvil;
|
import nmd.primal.forgecraft.tiles.TileAnvil;
|
||||||
import nmd.primal.forgecraft.tiles.TileForge;
|
import nmd.primal.forgecraft.tiles.TileForge;
|
||||||
@@ -77,10 +78,29 @@ public class Anvil extends CustomContainerFacing {
|
|||||||
// Crafting
|
// Crafting
|
||||||
// ***************************************************************************** //
|
// ***************************************************************************** //
|
||||||
if(pItem.getItem() == PrimalItems.STONE_GALLAGHER){
|
if(pItem.getItem() == PrimalItems.STONE_GALLAGHER){
|
||||||
/*
|
System.out.println("Use the ghallegher");
|
||||||
Loop through stacks in slot and create unique id from slots with stacks
|
StringBuilder craftingIDBuilder = new StringBuilder();
|
||||||
if unique ID matches then do crafting
|
//craftingIDBuilder.append("");
|
||||||
*/
|
int craftingID = 0;
|
||||||
|
for(int i=0; i<tile.getSlotListSize(); i++){
|
||||||
|
if(!tile.getSlotStack(i).isEmpty()){
|
||||||
|
craftingIDBuilder.append(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
craftingID = Integer.parseInt(craftingIDBuilder.toString());
|
||||||
|
System.out.println(craftingID);
|
||||||
|
AnvilCrafting recipe = AnvilCrafting.getRecipe(craftingID);
|
||||||
|
if(recipe != null){
|
||||||
|
CommonUtils.spawnItemEntity(world, player, recipe.getOutput());
|
||||||
|
for(int i=0; i<tile.getSlotListSize(); i++){
|
||||||
|
if(!tile.getSlotStack(i).isEmpty()){
|
||||||
|
tile.setSlotStack(i, ItemStack.EMPTY);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
package nmd.primal.forgecraft.crafting;
|
package nmd.primal.forgecraft.crafting;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
|
||||||
|
import static javax.swing.UIManager.put;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mminaie on 3/5/17.
|
* Created by mminaie on 3/5/17.
|
||||||
@@ -22,13 +26,30 @@ public class AnvilCrafting {
|
|||||||
|
|
||||||
private static ItemStack [] slots = {slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24};
|
private static ItemStack [] slots = {slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24};
|
||||||
|
|
||||||
private static Integer [] pickaxeHead = {
|
private static int[] craftingIDs = {6781014};
|
||||||
0,0,0,0,0,
|
|
||||||
0,1,1,1,0,
|
public static int getCraftingIDs(Integer x) {
|
||||||
1,0,0,0,1,
|
return craftingIDs[x];
|
||||||
0,0,0,0,0,
|
}
|
||||||
0,0,0,0,0
|
|
||||||
};
|
public static int[] getCraftingIDArray() {
|
||||||
|
return craftingIDs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ItemStack[] craftable = {new ItemStack(Blocks.OBSIDIAN, 1)};
|
||||||
|
|
||||||
|
public static ItemStack getCraftable(Integer x) {
|
||||||
|
return craftable[x];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*public static Hashtable<Integer, ItemStack> anvilReference = new Hashtable<Integer, ItemStack>(){{
|
||||||
|
|
||||||
|
put(6781014, new ItemStack(Blocks.OBSIDIAN, 1));
|
||||||
|
|
||||||
|
//put(3, ModItems.battleAxe);
|
||||||
|
|
||||||
|
}};*/
|
||||||
|
|
||||||
public static ItemStack getSlots(Integer x) {
|
public static ItemStack getSlots(Integer x) {
|
||||||
return slots[x];
|
return slots[x];
|
||||||
@@ -40,34 +61,9 @@ public class AnvilCrafting {
|
|||||||
|
|
||||||
private ItemStack output;
|
private ItemStack output;
|
||||||
|
|
||||||
public AnvilCrafting(Integer input, ItemStack slot0, ItemStack slot1, ItemStack slot2, ItemStack slot3, ItemStack slot4, ItemStack slot5, ItemStack slot6, ItemStack slot7, ItemStack slot8, ItemStack slot9, ItemStack slot10, ItemStack slot11, ItemStack slot12, ItemStack slot13, ItemStack slot14, ItemStack slot15, ItemStack slot16, ItemStack slot17, ItemStack slot18, ItemStack slot19, ItemStack slot20, ItemStack slot21, ItemStack slot22, ItemStack slot23, ItemStack slot24, ItemStack output){
|
public AnvilCrafting(Integer input, ItemStack output){
|
||||||
|
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.slot0 = slot0;
|
|
||||||
this.slot1 = slot1;
|
|
||||||
this.slot2 = slot2;
|
|
||||||
this.slot3 = slot3;
|
|
||||||
this.slot4 = slot4;
|
|
||||||
this.slot5 = slot5;
|
|
||||||
this.slot6 = slot6;
|
|
||||||
this.slot7 = slot7;
|
|
||||||
this.slot8 = slot8;
|
|
||||||
this.slot9 = slot9;
|
|
||||||
this.slot10 = slot10;
|
|
||||||
this.slot11 = slot11;
|
|
||||||
this.slot12 = slot12;
|
|
||||||
this.slot13 = slot13;
|
|
||||||
this.slot14 = slot14;
|
|
||||||
this.slot15 = slot15;
|
|
||||||
this.slot16 = slot16;
|
|
||||||
this.slot17 = slot17;
|
|
||||||
this.slot18 = slot18;
|
|
||||||
this.slot19 = slot19;
|
|
||||||
this.slot20 = slot20;
|
|
||||||
this.slot21 = slot21;
|
|
||||||
this.slot22 = slot22;
|
|
||||||
this.slot23 = slot23;
|
|
||||||
this.slot24 = slot24;
|
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -76,31 +72,33 @@ public class AnvilCrafting {
|
|||||||
// Recipe Methods
|
// Recipe Methods
|
||||||
// ***************************************************************************** //
|
// ***************************************************************************** //
|
||||||
|
|
||||||
public static void addRecipe(Integer input, ItemStack slot0, ItemStack slot1, ItemStack slot2, ItemStack slot3, ItemStack slot4, ItemStack slot5, ItemStack slot6, ItemStack slot7, ItemStack slot8, ItemStack slot9, ItemStack slot10, ItemStack slot11, ItemStack slot12, ItemStack slot13, ItemStack slot14, ItemStack slot15, ItemStack slot16, ItemStack slot17, ItemStack slot18, ItemStack slot19, ItemStack slot20, ItemStack slot21, ItemStack slot22, ItemStack slot23, ItemStack slot24, ItemStack output)
|
public static void addRecipe(Integer input, ItemStack output)
|
||||||
{
|
{
|
||||||
anvilRecipes.add(new AnvilCrafting(input, slot0, slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, output));
|
anvilRecipes.add(new AnvilCrafting(input, output));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRecipeItem(ItemStack stack)
|
public static boolean isRecipeItem(Integer craftingID)
|
||||||
{
|
{
|
||||||
for(AnvilCrafting recipe : anvilRecipes) {
|
for(AnvilCrafting recipe : anvilRecipes) {
|
||||||
for(int i=0; i<25; i++){
|
for(int i=0; i < AnvilCrafting.craftingIDs.length ; i++){
|
||||||
if (AnvilCrafting.getSlots(i).equals(stack))
|
if (craftingID.equals(getCraftingIDs(i)))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AnvilCrafting getRecipe(ItemStack stack)
|
public static AnvilCrafting getRecipe(Integer id)
|
||||||
{
|
{
|
||||||
for(AnvilCrafting recipe : anvilRecipes) {
|
for(AnvilCrafting recipe : anvilRecipes) {
|
||||||
if (stack.equals(recipe.output))
|
for (int i = 0; i < AnvilCrafting.craftingIDs.length; i++) {
|
||||||
|
if (id.equals(getCraftingIDs(i)))
|
||||||
return recipe;
|
return recipe;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getOutput() {return this.output;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,14 +150,7 @@ public class ModCrafting {
|
|||||||
// ANVILING
|
// ANVILING
|
||||||
// ***************************************************************************** //
|
// ***************************************************************************** //
|
||||||
|
|
||||||
AnvilCrafting.addRecipe(6781014, ItemStack.EMPTY, ItemStack.EMPTY, ItemStack.EMPTY, ItemStack.EMPTY, ItemStack.EMPTY,
|
AnvilCrafting.addRecipe(6781014, new ItemStack(Blocks.OBSIDIAN, 1));
|
||||||
ItemStack.EMPTY, new ItemStack(ModItems.ironchunkhot, 1), new ItemStack(ModItems.ironchunkhot, 1), new ItemStack(ModItems.ironchunkhot, 1), ItemStack.EMPTY,
|
|
||||||
ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,
|
|
||||||
ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,
|
|
||||||
ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,ItemStack.EMPTY,
|
|
||||||
new ItemStack(Blocks.OBSIDIAN, 1)
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user