diff --git a/kfc/src/main/java/nmd/primal/forgecraft/CommonEvents.java b/kfc/src/main/java/nmd/primal/forgecraft/CommonEvents.java index fb44c6bc..fc20081e 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/CommonEvents.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/CommonEvents.java @@ -39,8 +39,13 @@ public class CommonEvents implements WeaponNBT { public void onItemCrafted(CauldronRecipeEvent.Pre event){ CauldronRecipe recipe = event.getRecipe(); - - if (recipe.matches("rawbronzegladiussmite", "rawbronzegladiusbane", "rawbronzegladiuslapis")){ + System.out.println(recipe.getRecipeName()); + if (recipe.matches("forgecraft:cauldron_item.rawcoppergladiussmite", "forgecraft:cauldron_item.rawcoppergladiusbane", "forgecraft:cauldron_item.rawcoppergladiusfire", "forgecraft:cauldron_item.rawcoppergladiusfortune", + "forgecraft:cauldron_item.rawbronzegladiussmite", "forgecraft:cauldron_item.rawbronzegladiusbane", "forgecraft:cauldron_item.rawbronzegladiusfire", "forgecraft:cauldron_item.rawbronzegladiusfortune", + "forgecraft:cauldron_item.rawwroughtirongladiussmite", "forgecraft:cauldron_item.rawwroughtirongladiusbane", "forgecraft:cauldron_item.rawwroughtirongladiusfire", "forgecraft:cauldron_item.rawwroughtirongladiusfortune", + "forgecraft:cauldron_item.rawclearnirongladiussmite", "forgecraft:cauldron_item.rawclearnirongladiusbane", "forgecraft:cauldron_item.rawclearnirongladiusfire", "forgecraft:cauldron_item.rawclearnirongladiusfortune", + "forgecraft:cauldron_item.rawsteelgladiussmite", "forgecraft:cauldron_item.rawsteelgladiusbane", "forgecraft:cauldron_item.rawsteelgladiusfire", "forgecraft:cauldron_item.rawsteelgladiusfortune", + "forgecraft:cauldron_item.rawwootzgladiussmite", "forgecraft:cauldron_item.rawwootzgladiusbane", "forgecraft:cauldron_item.rawwootzgladiusfire", "forgecraft:cauldron_item.rawwootzgladiusfortune")){ NonNullList inputList = NonNullList.withSize(6, ItemStack.EMPTY); inputList.set(0, event.getTile().getInputHandler().getStackInSlot(0)); @@ -61,31 +66,27 @@ public class CommonEvents implements WeaponNBT { modStack = getOppositeStack(inputList, inputStack); - if (inputStack.hasTagCompound()) { - if (inputStack.getSubCompound("tags") != null) { - NBTTagCompound tags = inputStack.getTagCompound().copy(); - if(inputStackItem != null) { - if (getModifiers(inputStack) < WeaponNBT.materialModifiers.get(((WeaponPart) outputStack.getItem()).getMaterial()) ) { - if (RecipeHelper.isOreName(modStack, "dustSilver")) { - setSmiteLevel(outputStack, getSmiteLevel(inputStack) + 1); - setModifiers(outputStack, getModifiers(inputStack) + 1); - } - if (RecipeHelper.isOreName(modStack, "foodPoison")) { - setBaneLevel(outputStack, getBaneLevel(inputStack) + 1); - setModifiers(outputStack, getModifiers(inputStack) + 1); - } - if (RecipeHelper.isOreName(modStack, "dustBlaze")) { - setFireLevel(outputStack, getFireLevel(inputStack) + 1); - setModifiers(outputStack, getModifiers(inputStack) + 1); - } - if (RecipeHelper.isOreName(modStack, "gemLapis")) { - setFortuneLevel(outputStack, getFortuneLevel(inputStack) + 1); - setModifiers(outputStack, getModifiers(inputStack) + 1); - } - if (RecipeHelper.isOreName(modStack, "boneWithered", "dustWitheredBone", "skullWithered")) { - setLeechLevel(outputStack, getLeechLevel(inputStack) + 1); - setModifiers(outputStack, getModifiers(inputStack) + 1); - } + if(inputStackItem != null) { + System.out.println("Stack is not null"); + if (inputStack.hasTagCompound()) { + System.out.println("Stack Has NBT"); + if (getModifiers(inputStack) < WeaponNBT.materialModifiers.get(((WeaponPart) outputStack.getItem()).getMaterial()) ) { + if (RecipeHelper.isOreName(modStack, "dustSilver")) { + setSmiteLevel(outputStack, getSmiteLevel(inputStack) + 1); + setModifiers(outputStack, getModifiers(inputStack) + 1); + } + if (RecipeHelper.isOreName(modStack, "foodPoison")) { + setBaneLevel(outputStack, getBaneLevel(inputStack) + 1); + setModifiers(outputStack, getModifiers(inputStack) + 1); + } + if (RecipeHelper.isOreName(modStack, "dustBlaze")) { + setFireLevel(outputStack, getFireLevel(inputStack) + 1); + setModifiers(outputStack, getModifiers(inputStack) + 1); + } + if (RecipeHelper.isOreName(modStack, "gemLapis")) { + System.out.println("We are doign Gem Lapis Things"); + setFortuneLevel(outputStack, getFortuneLevel(inputStack) + 1); + setModifiers(outputStack, getModifiers(inputStack) + 1); } } } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/NBTCrucible.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/NBTCrucible.java index b700a444..3784ae34 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/NBTCrucible.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/NBTCrucible.java @@ -34,6 +34,8 @@ import nmd.primal.forgecraft.tiles.TileNBTCrucible; import java.util.Random; +import static net.minecraft.util.EnumHand.MAIN_HAND; + /** * Created by mminaie on 11/11/17. @@ -58,8 +60,14 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing face, float hitX, float hitY, float hitZ) { if (!world.isRemote) { - if(hand.equals(hand.MAIN_HAND)) { - TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos); + + TileNBTCrucible tile = (TileNBTCrucible) world.getTileEntity(pos); + + if(hand.equals(MAIN_HAND)) { + + System.out.println(player.inventory.getCurrentItem()); + System.out.println(hand); + ItemStack pItem = player.inventory.getCurrentItem().copy(); pItem.setCount(1); @@ -76,11 +84,15 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { return true; } } + } - /**SET INGREDIENT ARRAY FOR THE CRUCIBLE NOW**/ + /**SET INGREDIENT ARRAY FOR THE CRUCIBLE NOW**/ + if( player.inventory.getSlotFor(player.inventory.getCurrentItem()) != -1 ) { + ItemStack pItem = player.inventory.getCurrentItem().copy(); + pItem.setCount(1); if (!player.isSneaking()) { if (!pItem.isEmpty()) { - if(!tile.getStatus() || tile.getHot() == 15 || tile.getHot() == 6) { + if (!tile.getStatus() || tile.getHot() == 15 || tile.getHot() == 6) { if (pItem.getItem() instanceof SlottedTongs) { return false; } else { @@ -101,10 +113,13 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { } } } + } /**CLEARS THE INVENTORY**/ + if(hand.equals(MAIN_HAND)) { if (player.isSneaking()) { + ItemStack pItem = player.inventory.getCurrentItem().copy(); if (pItem.isEmpty()) { - if (tile.getHot()!=15) { + if (tile.getHot() != 15) { if (!tile.getStatus()) { for (int i = 0; i < tile.ingList.size(); i++) { if (!tile.ingList.get(i).isEmpty()) { @@ -122,10 +137,13 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { } } } + } /**REMOVE COOKED ITEM**/ - if (player.isSneaking() == true) { + if (player.isSneaking() == true) { + if (hand.equals(MAIN_HAND)) { + ItemStack pItem = player.inventory.getCurrentItem().copy(); if (pItem.isEmpty()) { - if (tile.getStatus() && tile.getHot()==6) { + if (tile.getStatus() && tile.getHot() == 6) { ItemStack dropStack = tile.getDrops().copy(); world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2); tile.setHot(0); @@ -142,7 +160,6 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider { } } } - return true; } } return false; diff --git a/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Workbench.java b/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Workbench.java index d1c4ebcd..fcc2bd93 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Workbench.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/blocks/machine/Workbench.java @@ -12,9 +12,12 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import nmd.primal.core.common.helper.PlayerHelper; +import nmd.primal.core.common.helper.RecipeHelper; import nmd.primal.core.common.items.tools.Gallagher; import nmd.primal.forgecraft.blocks.CustomContainerFacing; import nmd.primal.forgecraft.crafting.WorkbenchCrafting; +import nmd.primal.forgecraft.items.parts.ToolPart; +import nmd.primal.forgecraft.items.parts.WeaponPart; import nmd.primal.forgecraft.tiles.TileWorkbench; import javax.annotation.Nullable; @@ -92,8 +95,8 @@ public class Workbench extends CustomContainerFacing { } if(playerStack.getItem() instanceof Gallagher) { if (!slot2.isEmpty() && !slot3.isEmpty() && !slot4.isEmpty() && slot5.isEmpty()) { + WorkbenchCrafting recipe = WorkbenchCrafting.getRecipe(slot2, slot3, slot4, slot5); - System.out.println(slot5); if (recipe != null) { ItemStack drops = recipe.getOutput(); if (slot3.hasTagCompound()) { diff --git a/kfc/src/main/java/nmd/primal/forgecraft/crafting/WorkbenchCrafting.java b/kfc/src/main/java/nmd/primal/forgecraft/crafting/WorkbenchCrafting.java index 42fb904d..64e7b2ad 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/crafting/WorkbenchCrafting.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/crafting/WorkbenchCrafting.java @@ -4,6 +4,7 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.registries.IForgeRegistry; +import nmd.primal.core.common.helper.RecipeHelper; import nmd.primal.core.common.recipes.AbstractRecipe; import nmd.primal.forgecraft.ModInfo; @@ -102,17 +103,16 @@ public class WorkbenchCrafting extends AbstractRecipe { //ext if(ingredient == null && stack.isEmpty()) { return true; } - if (ingredient.test(ItemStack.EMPTY)) { if (stack.isEmpty()) { return true; } } - - if(ingredient.apply(stack)){ + ItemStack[] testArray = ingredient.getMatchingStacks(); + List testList = RecipeHelper.buildList(testArray); + if(testList.contains(stack)){ return true; } - return false; } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/crafting/registery/RecipesWorkbench.java b/kfc/src/main/java/nmd/primal/forgecraft/crafting/registery/RecipesWorkbench.java index 571a7604..43527a7a 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/crafting/registery/RecipesWorkbench.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/crafting/registery/RecipesWorkbench.java @@ -380,8 +380,8 @@ public final class RecipesWorkbench { recipes.register (new WorkbenchCrafting( new OreIngredient("weaponHandle"), - new OreIngredient("weaponGuard"), Ingredient.fromStacks(new ItemStack(ModItems.rawbronzegladius, 1)), + new OreIngredient("weaponGuard"), Ingredient.EMPTY, new ItemStack(ModItems.bronzegladius, 1)).setRecipeName("bronzegladius")); diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/parts/WeaponPart.java b/kfc/src/main/java/nmd/primal/forgecraft/items/parts/WeaponPart.java index 71b9a29d..dae29056 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/parts/WeaponPart.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/parts/WeaponPart.java @@ -118,24 +118,24 @@ public class WeaponPart extends Item implements WeaponNBT { if(stack.hasTagCompound()) { if (stack.getSubCompound("tags") != null) { tooltip.add(ChatFormatting.GRAY + "Upgrades left: " + (WeaponNBT.materialModifiers.get(this.toolMaterial) - getModifiers(stack))); - } - if (getSmiteLevel(stack) > 0) { - tooltip.add(ChatFormatting.GOLD + "Holy: " + getSmiteLevel(stack)); - } - if (getBaneLevel(stack) > 0) { - tooltip.add(ChatFormatting.GREEN + "Spider Killing: " + getBaneLevel(stack)); - } - if (getFireLevel(stack) > 0) { - tooltip.add(ChatFormatting.RED + "Flame: " + getFireLevel(stack)); - } - if (getFortuneLevel(stack) > 0) { - tooltip.add(ChatFormatting.BLUE + "Thieving: " + getFortuneLevel(stack)); - } - if (getLeechLevel(stack) > 0) { - tooltip.add(ChatFormatting.BLACK + "Life Steal: " + getLeechLevel(stack)); - } - if(getSharpnessLevel(stack)>0){ - tooltip.add(ChatFormatting.WHITE + "Sharpness: " + getSharpnessLevel(stack)); + if (getSmiteLevel(stack) > 0) { + tooltip.add(ChatFormatting.GOLD + "Holy: " + getSmiteLevel(stack)); + } + if (getBaneLevel(stack) > 0) { + tooltip.add(ChatFormatting.GREEN + "Spider Killing: " + getBaneLevel(stack)); + } + if (getFireLevel(stack) > 0) { + tooltip.add(ChatFormatting.RED + "Flame: " + getFireLevel(stack)); + } + if (getFortuneLevel(stack) > 0) { + tooltip.add(ChatFormatting.BLUE + "Thieving: " + getFortuneLevel(stack)); + } + if (getLeechLevel(stack) > 0) { + tooltip.add(ChatFormatting.BLACK + "Life Steal: " + getLeechLevel(stack)); + } + if (getSharpnessLevel(stack) > 0) { + tooltip.add(ChatFormatting.WHITE + "Sharpness: " + getSharpnessLevel(stack)); + } } } } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/items/weapons/CustomSword.java b/kfc/src/main/java/nmd/primal/forgecraft/items/weapons/CustomSword.java index 1b21c6e6..170486ff 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/items/weapons/CustomSword.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/items/weapons/CustomSword.java @@ -16,6 +16,7 @@ import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import nmd.primal.forgecraft.ModInfo; +import nmd.primal.forgecraft.util.WeaponNBT; import javax.annotation.Nullable; import java.util.List; @@ -23,11 +24,11 @@ import java.util.List; /** * Created by mminaie on 3/23/17. */ -public class CustomSword extends ItemSword { +public class CustomSword extends ItemSword implements WeaponNBT { private double attack, speed; - - public CustomSword(String name, Item.ToolMaterial material, double attackDamage, double attackSpeed) { + private ToolMaterial toolMaterial; + public CustomSword(String name, ToolMaterial material, double attackDamage, double attackSpeed) { super(material); this.setUnlocalizedName(name); this.setRegistryName(name); @@ -36,7 +37,7 @@ public class CustomSword extends ItemSword { this.setNoRepair(); this.attack = attackDamage; this.speed = attackSpeed; - + this.toolMaterial= material; } @SideOnly(Side.CLIENT) @@ -79,13 +80,30 @@ public class CustomSword extends ItemSword { @Override @SideOnly(Side.CLIENT) - public void addInformation(ItemStack item, @Nullable World world, List tooltip, ITooltipFlag flagIn) + public void addInformation(ItemStack stack, @Nullable World world, List tooltip, ITooltipFlag flagIn) { //tooltip.add(ChatFormatting.GRAY + "Damage: " + item.getItemDamage() ); - if(item.hasTagCompound()) + if(stack.hasTagCompound()) { - tooltip.add(ChatFormatting.GRAY + "Upgrades: " ); - tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() ); + tooltip.add(ChatFormatting.GRAY + "Upgrades left: " + (WeaponNBT.materialModifiers.get(this.toolMaterial) - getModifiers(stack))); + if (getSmiteLevel(stack) > 0) { + tooltip.add(ChatFormatting.GOLD + "Holy: " + getSmiteLevel(stack)); + } + if (getBaneLevel(stack) > 0) { + tooltip.add(ChatFormatting.GREEN + "Spider Killing: " + getBaneLevel(stack)); + } + if (getFireLevel(stack) > 0) { + tooltip.add(ChatFormatting.RED + "Flame: " + getFireLevel(stack)); + } + if (getFortuneLevel(stack) > 0) { + tooltip.add(ChatFormatting.BLUE + "Thieving: " + getFortuneLevel(stack)); + } + if (getLeechLevel(stack) > 0) { + tooltip.add(ChatFormatting.BLACK + "Life Steal: " + getLeechLevel(stack)); + } + if (getSharpnessLevel(stack) > 0) { + tooltip.add(ChatFormatting.WHITE + "Sharpness: " + getSharpnessLevel(stack)); + } } } diff --git a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileWorkbench.java b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileWorkbench.java index f1542625..59d39187 100644 --- a/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileWorkbench.java +++ b/kfc/src/main/java/nmd/primal/forgecraft/tiles/TileWorkbench.java @@ -40,13 +40,12 @@ public class TileWorkbench extends TileBaseSlot{ } }*/ if(index == 3){ - if ( (stack.getItem() instanceof ToolPart) || stack.getItem() instanceof WeaponGuard) { + if ( (stack.getItem() instanceof ToolPart) || stack.getItem() instanceof WeaponPart) { return true; } } if(index == 4){ - if ( (RecipeHelper.isOreName(stack.getItem(), "pinBasic")) || - stack.getItem() instanceof WeaponPart) { + if ( (RecipeHelper.isOreName(stack.getItem(), "pinBasic")) || stack.getItem() instanceof WeaponGuard) { return true; } }