working on anvil logic to support output of upgrades via NBT
This commit is contained in:
@@ -10,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -25,6 +26,7 @@ import nmd.primal.forgecraft.CommonUtils;
|
||||
import nmd.primal.forgecraft.ModInfo;
|
||||
import nmd.primal.forgecraft.crafting.AnvilCrafting;
|
||||
import nmd.primal.forgecraft.init.ModItems;
|
||||
import nmd.primal.forgecraft.items.toolparts.ToolPart;
|
||||
import nmd.primal.forgecraft.tiles.TileAnvil;
|
||||
import nmd.primal.forgecraft.tiles.TileForge;
|
||||
|
||||
@@ -96,7 +98,39 @@ public class Anvil extends CustomContainerFacing {
|
||||
if(pItem.getItem().equals(ModItems.forgehammer)) {
|
||||
pItem.damageItem(1, player);
|
||||
}
|
||||
|
||||
if(recipe.getOutput().getItem() instanceof ToolPart){
|
||||
NBTTagCompound tempNBT = tile.getSlotStack(12).getSubCompound("tags");
|
||||
ItemStack outputStack = recipe.getOutput();
|
||||
outputStack.getTagCompound().setTag("tags", tempNBT);
|
||||
outputStack.getSubCompound("tags").setBoolean("hot", false);
|
||||
|
||||
if(outputStack.getSubCompound("tags").getInteger("modifiers") < 3){
|
||||
|
||||
//Upgrade Redstone
|
||||
if(recipe.getUpgrade() == "redstone"){
|
||||
outputStack.getSubCompound("tags").setInteger("redstone",
|
||||
(outputStack.getSubCompound("tags").getInteger("redstone") + 1) );
|
||||
outputStack.getSubCompound("tags").setInteger("modifiers",
|
||||
(outputStack.getSubCompound("tags").getInteger("modifiers") + 1) );
|
||||
}
|
||||
|
||||
}
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos, outputStack);
|
||||
|
||||
} else {
|
||||
CommonUtils.spawnItemEntityFromWorld(world, pos, recipe.getOutput());
|
||||
}
|
||||
|
||||
/*
|
||||
NBTTagCompound tempNBT = this.getSlotStack(i).getSubCompound("tags");
|
||||
ItemStack outputStack = recipe.getOutput();
|
||||
outputStack.getTagCompound().setTag("tags", tempNBT);
|
||||
outputStack.getSubCompound("tags").setBoolean("hot", true);
|
||||
this.setSlotStack(i, outputStack);
|
||||
*/
|
||||
|
||||
|
||||
world.playEvent(1031, pos, 0);
|
||||
for (int i = 0; i < tile.getSlotListSize(); i++) {
|
||||
if (!tile.getSlotStack(i).isEmpty()) {
|
||||
@@ -138,6 +172,7 @@ public class Anvil extends CustomContainerFacing {
|
||||
//System.out.println(counter);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +188,15 @@ public class Anvil extends CustomContainerFacing {
|
||||
//System.out.println(counter);
|
||||
return true;
|
||||
}
|
||||
if (pItem.getTagCompound().getInteger("type") == 8) {
|
||||
ItemStack tempStack = new ItemStack (ModItems.pickaxehead, 1);
|
||||
//tempStack.
|
||||
|
||||
//tile.setSlotStack((counter), new ItemStack);
|
||||
pItem.getTagCompound().setInteger("type", 0);
|
||||
//System.out.println(counter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,22 +22,17 @@ public class AnvilCrafting {
|
||||
|
||||
private static ArrayList<AnvilCrafting> anvilRecipes = new ArrayList<>();
|
||||
|
||||
//private Integer[] input = new Integer[25];
|
||||
|
||||
private String[] input = new String[25];
|
||||
|
||||
//private ItemStack inputItem;
|
||||
|
||||
//private static Item 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 Item[] 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};
|
||||
private String upgradeType;
|
||||
|
||||
private ItemStack output;
|
||||
|
||||
public AnvilCrafting(String[] input, ItemStack output){
|
||||
public AnvilCrafting(String[] input, ItemStack output, String upgrade){
|
||||
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
this.upgradeType = upgrade;
|
||||
|
||||
}
|
||||
|
||||
@@ -45,9 +40,9 @@ public class AnvilCrafting {
|
||||
// Recipe Methods
|
||||
// ***************************************************************************** //
|
||||
|
||||
public static void addRecipe(String[] input, ItemStack output)
|
||||
public static void addRecipe(String[] input, ItemStack output, String upgrade)
|
||||
{
|
||||
anvilRecipes.add(new AnvilCrafting(input, output));
|
||||
anvilRecipes.add(new AnvilCrafting(input, output, upgrade));
|
||||
}
|
||||
|
||||
public static boolean isRecipe(String[] array)
|
||||
@@ -73,4 +68,6 @@ public class AnvilCrafting {
|
||||
|
||||
public ItemStack getOutput() {return this.output;}
|
||||
|
||||
public String getUpgrade() {return this.upgradeType; }
|
||||
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ public class ForgeCrafting {
|
||||
private static ArrayList<ForgeCrafting> forgeRecipes = new ArrayList<>();
|
||||
|
||||
private Item input;
|
||||
private Item output;
|
||||
private ItemStack output;
|
||||
|
||||
private int heat_threshold;
|
||||
private int ideal_time;
|
||||
private int cooldown;
|
||||
|
||||
|
||||
public ForgeCrafting(Item input, Item output, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance)
|
||||
public ForgeCrafting(Item input, ItemStack output, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance)
|
||||
{
|
||||
this.input = input;
|
||||
this.output = output;
|
||||
@@ -38,7 +38,7 @@ public class ForgeCrafting {
|
||||
// ***************************************************************************** //
|
||||
// Recipe Methods
|
||||
// ***************************************************************************** //
|
||||
public static void addRecipe(Item input, Item output, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance)
|
||||
public static void addRecipe(Item input, ItemStack output, int heat_threshold, int ideal_time, int cooldown, float heat_variance, float time_variance)
|
||||
{
|
||||
forgeRecipes.add(new ForgeCrafting(input, output, heat_threshold, ideal_time, cooldown, heat_variance, time_variance));
|
||||
}
|
||||
@@ -61,21 +61,21 @@ public class ForgeCrafting {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ForgeCrafting getRecipeFromOutput(Item item)
|
||||
/*public static ForgeCrafting getRecipeFromOutput(Item item)
|
||||
{
|
||||
for(ForgeCrafting recipe : forgeRecipes) {
|
||||
if (item.equals(recipe.output))
|
||||
return recipe;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}*/
|
||||
|
||||
public Item getInput()
|
||||
{
|
||||
return this.input;
|
||||
}
|
||||
|
||||
public Item getOutput() {return this.output; }
|
||||
public ItemStack getOutput() {return this.output; }
|
||||
|
||||
public int getHeatThreshold()
|
||||
{
|
||||
|
||||
@@ -137,14 +137,14 @@ public class ModCrafting {
|
||||
0.5f
|
||||
);
|
||||
|
||||
// ***************************************************************************** //
|
||||
// FORGING
|
||||
// ***************************************************************************** //
|
||||
/******************************************************************************
|
||||
FORGING
|
||||
******************************************************************************/
|
||||
|
||||
//Makes a Hot Iron Ingot
|
||||
ForgeCrafting.addRecipe(
|
||||
Item.getItemFromBlock(ModBlocks.ironball),
|
||||
ModItems.ironingotballhot,
|
||||
new ItemStack(ModItems.ironingotballhot, 1),
|
||||
800,
|
||||
200,
|
||||
500,
|
||||
@@ -155,7 +155,7 @@ public class ModCrafting {
|
||||
//Makes a Hot Iron Chunk
|
||||
ForgeCrafting.addRecipe(
|
||||
Item.getItemFromBlock(ModBlocks.ironchunk),
|
||||
ModItems.ironchunkhot,
|
||||
new ItemStack(ModItems.ironchunkhot,1),
|
||||
800,
|
||||
160,
|
||||
400,
|
||||
@@ -163,9 +163,21 @@ public class ModCrafting {
|
||||
1.0f
|
||||
);
|
||||
|
||||
// ***************************************************************************** //
|
||||
// ANVILING
|
||||
// ***************************************************************************** //
|
||||
//Makes a Hot PickaxeHead
|
||||
ForgeCrafting.addRecipe(
|
||||
ModItems.pickaxehead,
|
||||
new ItemStack(ModItems.pickaxehead, 1 ),
|
||||
800,
|
||||
160,
|
||||
400,
|
||||
1.0f,
|
||||
1.0f
|
||||
);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
ANVILING
|
||||
******************************************************************************/
|
||||
|
||||
String empty = ItemStack.EMPTY.getItem().getRegistryName().toString();
|
||||
String hotChunk = ModItems.ironchunkhot.getRegistryName().toString();
|
||||
@@ -186,7 +198,8 @@ public class ModCrafting {
|
||||
empty,empty,hotChunk,empty,empty,
|
||||
empty,empty,hotChunk,empty,empty,
|
||||
empty,empty,hotChunk,empty,empty },
|
||||
new ItemStack(ModItems.forgehammer, 1)
|
||||
new ItemStack(ModItems.forgehammer, 1),
|
||||
"null"
|
||||
);
|
||||
|
||||
//Makes flaked diamond
|
||||
@@ -197,7 +210,8 @@ public class ModCrafting {
|
||||
empty,empty,diamond,empty,empty,
|
||||
empty,empty,empty,empty,empty,
|
||||
empty,empty,empty,empty,empty },
|
||||
new ItemStack(PrimalItems.DIAMOND_KNAPP, 1)
|
||||
new ItemStack(PrimalItems.DIAMOND_KNAPP, 1),
|
||||
"null"
|
||||
);
|
||||
|
||||
//Makes flaked emerald
|
||||
@@ -208,7 +222,8 @@ public class ModCrafting {
|
||||
empty,empty,emerald,empty,empty,
|
||||
empty,empty,empty,empty,empty,
|
||||
empty,empty,empty,empty,empty },
|
||||
new ItemStack(PrimalItems.EMERALD_KNAPP, 1)
|
||||
new ItemStack(PrimalItems.EMERALD_KNAPP, 1),
|
||||
"null"
|
||||
);
|
||||
|
||||
//Makes a Pickaxe Head
|
||||
@@ -219,9 +234,20 @@ public class ModCrafting {
|
||||
hotChunk,empty,empty,empty,hotChunk,
|
||||
empty,empty,empty,empty,empty,
|
||||
empty,empty,empty,empty,empty },
|
||||
new ItemStack(Blocks.OBSIDIAN, 1)
|
||||
new ItemStack(ModItems.pickaxehead, 1),
|
||||
"null"
|
||||
);
|
||||
//Makes a Redstone Upgrade to Pickaxe Head
|
||||
AnvilCrafting.addRecipe(
|
||||
new String[] {
|
||||
empty,empty,empty,empty,empty,
|
||||
empty,empty,empty,empty,empty,
|
||||
empty,empty,empty,empty,empty,
|
||||
empty,empty,empty,empty,empty,
|
||||
empty,empty,empty,empty,empty },
|
||||
new ItemStack(ModItems.pickaxehead, 1),
|
||||
"redstone"
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +127,8 @@ public class ModItems {
|
||||
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_hotironcooked"),
|
||||
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_hotironfailed"),
|
||||
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_ingot"),
|
||||
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_chunk")
|
||||
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_chunk"),
|
||||
new ResourceLocation(ModInfo.MOD_ID, "stonetongs_pickaxe")
|
||||
);
|
||||
ModelLoader.setCustomMeshDefinition(ModItems.stonetongs, new ItemMeshDefinition() {
|
||||
|
||||
@@ -158,6 +159,9 @@ public class ModItems {
|
||||
else if (stack.getTagCompound().getInteger("type") == 7 ) {
|
||||
return new ModelResourceLocation(stack.getItem().getRegistryName() + "_chunk", "inventory");
|
||||
}
|
||||
else if (stack.getTagCompound().getInteger("type") == 8 ) {
|
||||
return new ModelResourceLocation(stack.getItem().getRegistryName() + "_pickaxe", "inventory");
|
||||
}
|
||||
else return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");
|
||||
}
|
||||
return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory");
|
||||
|
||||
@@ -39,6 +39,18 @@ public class ItemStoneTongs extends Item {
|
||||
//this.setDamage(item, 1000);
|
||||
item.getTagCompound().setInteger("type", 0);
|
||||
item.getTagCompound().setInteger("cooldown", 0);
|
||||
|
||||
//item.getTagCompound().setTag("toolpart", );
|
||||
|
||||
//item.getTagCompound().setBoolean("hot", false);
|
||||
|
||||
//item.getTagCompound().setBoolean("emerald", false);
|
||||
//item.getTagCompound().setInteger("diamond", 0);
|
||||
//item.getTagCompound().setInteger("redstone", 0);
|
||||
//item.getTagCompound().setInteger("lapis", 0);
|
||||
|
||||
//item.getTagCompound().setInteger("modifiers", 0);
|
||||
|
||||
//item.getTagCompound().setBoolean("active", false);
|
||||
}
|
||||
}
|
||||
@@ -54,8 +66,11 @@ public class ItemStoneTongs extends Item {
|
||||
4 | Hot Cooked Iron Crucible
|
||||
5 | Hot Failed Iron Crucible
|
||||
6 | Hot Iron Ingot
|
||||
7 | Hit Iron Chunk
|
||||
8 |
|
||||
7 | Hot Iron Chunk
|
||||
8 | Hot Pickaxe Head
|
||||
9 | Hot Shovel Head
|
||||
10 | Hot Axe Head
|
||||
11 | Hot Hoe Head
|
||||
*/
|
||||
|
||||
if(!world.isRemote) {
|
||||
@@ -181,7 +196,7 @@ public class ItemStoneTongs extends Item {
|
||||
world.setBlockState(tempPos, ModBlocks.ironchunk.getDefaultState().withProperty(IngotBall.ACTIVE, true), 3);
|
||||
itemstack.getTagCompound().setInteger("type", 0);
|
||||
return EnumActionResult.SUCCESS;
|
||||
case 8:
|
||||
case 9:
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
}
|
||||
@@ -217,6 +232,7 @@ public class ItemStoneTongs extends Item {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
else return EnumActionResult.FAIL;
|
||||
//System.out.println(itemstack.getTagCompound().getInteger("type"));
|
||||
}
|
||||
|
||||
@@ -200,14 +200,18 @@ public class PickaxePart extends ToolPart {
|
||||
|
||||
if (!item.hasTagCompound()) {
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
item.getTagCompound().setBoolean("hot", false);
|
||||
NBTTagCompound tags = new NBTTagCompound();
|
||||
|
||||
item.getTagCompound().setBoolean("emerald", false);
|
||||
item.getTagCompound().setInteger("diamond", 0);
|
||||
item.getTagCompound().setInteger("redstone", 0);
|
||||
item.getTagCompound().setInteger("lapis", 0);
|
||||
item.getTagCompound().setTag("tags", tags);
|
||||
|
||||
item.getTagCompound().setInteger("modifiers", 0);
|
||||
item.getSubCompound("tags").setBoolean("hot", false);
|
||||
|
||||
item.getSubCompound("tags").setBoolean("emerald", false);
|
||||
item.getSubCompound("tags").setInteger("diamond", 0);
|
||||
item.getSubCompound("tags").setInteger("redstone", 0);
|
||||
item.getSubCompound("tags").setInteger("lapis", 0);
|
||||
|
||||
item.getSubCompound("tags").setInteger("modifiers", 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -216,14 +220,18 @@ public class PickaxePart extends ToolPart {
|
||||
public void onUpdate(ItemStack item, World world, Entity player, int itemSlot, boolean isSelected) {
|
||||
if (!item.hasTagCompound()) {
|
||||
item.setTagCompound(new NBTTagCompound());
|
||||
item.getTagCompound().setBoolean("hot", false);
|
||||
NBTTagCompound tags = new NBTTagCompound();
|
||||
|
||||
item.getTagCompound().setBoolean("emerald", false);
|
||||
item.getTagCompound().setInteger("diamond", 0);
|
||||
item.getTagCompound().setInteger("redstone", 0);
|
||||
item.getTagCompound().setInteger("lapis", 0);
|
||||
item.getTagCompound().setTag("tags", tags);
|
||||
|
||||
item.getTagCompound().setInteger("modifiers", 0);
|
||||
item.getSubCompound("tags").setBoolean("hot", false);
|
||||
|
||||
item.getSubCompound("tags").setBoolean("emerald", false);
|
||||
item.getSubCompound("tags").setInteger("diamond", 0);
|
||||
item.getSubCompound("tags").setInteger("redstone", 0);
|
||||
item.getSubCompound("tags").setInteger("lapis", 0);
|
||||
|
||||
item.getSubCompound("tags").setInteger("modifiers", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,13 @@ public class TileForge extends TileBaseSlot implements ITickable {
|
||||
cookCounter2--;
|
||||
}
|
||||
if (cookCounter2 >= recipe.getIdealTime()) {
|
||||
this.setSlotStack(i, new ItemStack(recipe.getOutput(), 1));
|
||||
if(this.getSlotStack(i).hasTagCompound()){
|
||||
NBTTagCompound tempNBT = this.getSlotStack(i).getSubCompound("tags");
|
||||
ItemStack outputStack = recipe.getOutput();
|
||||
outputStack.getTagCompound().setTag("tags", tempNBT);
|
||||
outputStack.getSubCompound("tags").setBoolean("hot", true);
|
||||
this.setSlotStack(i, outputStack);
|
||||
} else this.setSlotStack(i, recipe.getOutput());
|
||||
cookCounter2 = 0;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +130,13 @@ public class TileForge extends TileBaseSlot implements ITickable {
|
||||
cookCounter3--;
|
||||
}
|
||||
if (cookCounter3 >= recipe.getIdealTime()) {
|
||||
this.setSlotStack(i, new ItemStack(recipe.getOutput(), 1));
|
||||
if(this.getSlotStack(i).hasTagCompound()){
|
||||
NBTTagCompound tempNBT = this.getSlotStack(i).getSubCompound("tags");
|
||||
ItemStack outputStack = recipe.getOutput();
|
||||
outputStack.getTagCompound().setTag("tags", tempNBT);
|
||||
outputStack.getSubCompound("tags").setBoolean("hot", true);
|
||||
this.setSlotStack(i, outputStack);
|
||||
} else this.setSlotStack(i, recipe.getOutput());
|
||||
cookCounter3 = 0;
|
||||
}
|
||||
}
|
||||
@@ -136,7 +148,13 @@ public class TileForge extends TileBaseSlot implements ITickable {
|
||||
cookCounter4--;
|
||||
}
|
||||
if (cookCounter4 >= recipe.getIdealTime()) {
|
||||
this.setSlotStack(i, new ItemStack(recipe.getOutput(), 1));
|
||||
if(this.getSlotStack(i).hasTagCompound()){
|
||||
NBTTagCompound tempNBT = this.getSlotStack(i).getSubCompound("tags");
|
||||
ItemStack outputStack = recipe.getOutput();
|
||||
outputStack.getTagCompound().setTag("tags", tempNBT);
|
||||
outputStack.getSubCompound("tags").setBoolean("hot", true);
|
||||
this.setSlotStack(i, outputStack);
|
||||
} else this.setSlotStack(i, recipe.getOutput());
|
||||
cookCounter4 = 0;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +166,13 @@ public class TileForge extends TileBaseSlot implements ITickable {
|
||||
cookCounter5--;
|
||||
}
|
||||
if (cookCounter5 >= recipe.getIdealTime()) {
|
||||
this.setSlotStack(i, new ItemStack(recipe.getOutput(), 1));
|
||||
if(this.getSlotStack(i).hasTagCompound()){
|
||||
NBTTagCompound tempNBT = this.getSlotStack(i).getSubCompound("tags");
|
||||
ItemStack outputStack = recipe.getOutput();
|
||||
outputStack.getTagCompound().setTag("tags", tempNBT);
|
||||
outputStack.getSubCompound("tags").setBoolean("hot", true);
|
||||
this.setSlotStack(i, outputStack);
|
||||
} else this.setSlotStack(i, recipe.getOutput());
|
||||
cookCounter5 = 0;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +184,13 @@ public class TileForge extends TileBaseSlot implements ITickable {
|
||||
cookCounter6--;
|
||||
}
|
||||
if (cookCounter6 >= recipe.getIdealTime()) {
|
||||
this.setSlotStack(i, new ItemStack(recipe.getOutput(), 1));
|
||||
if(this.getSlotStack(i).hasTagCompound()){
|
||||
NBTTagCompound tempNBT = this.getSlotStack(i).getSubCompound("tags");
|
||||
ItemStack outputStack = recipe.getOutput();
|
||||
outputStack.getTagCompound().setTag("tags", tempNBT);
|
||||
outputStack.getSubCompound("tags").setBoolean("hot", true);
|
||||
this.setSlotStack(i, outputStack);
|
||||
} else this.setSlotStack(i, recipe.getOutput());
|
||||
cookCounter6 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user