fixed a bug but in the wrong branch

This commit is contained in:
Mohammad-Ali Minaie
2018-10-20 11:06:35 -04:00
parent 2b9f131984
commit fec851e5af
8 changed files with 108 additions and 70 deletions

View File

@@ -39,8 +39,13 @@ public class CommonEvents implements WeaponNBT {
public void onItemCrafted(CauldronRecipeEvent.Pre event){ public void onItemCrafted(CauldronRecipeEvent.Pre event){
CauldronRecipe recipe = event.getRecipe(); CauldronRecipe recipe = event.getRecipe();
System.out.println(recipe.getRecipeName());
if (recipe.matches("rawbronzegladiussmite", "rawbronzegladiusbane", "rawbronzegladiuslapis")){ 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<ItemStack> inputList = NonNullList.<ItemStack>withSize(6, ItemStack.EMPTY); NonNullList<ItemStack> inputList = NonNullList.<ItemStack>withSize(6, ItemStack.EMPTY);
inputList.set(0, event.getTile().getInputHandler().getStackInSlot(0)); inputList.set(0, event.getTile().getInputHandler().getStackInSlot(0));
@@ -61,31 +66,27 @@ public class CommonEvents implements WeaponNBT {
modStack = getOppositeStack(inputList, inputStack); modStack = getOppositeStack(inputList, inputStack);
if (inputStack.hasTagCompound()) { if(inputStackItem != null) {
if (inputStack.getSubCompound("tags") != null) { System.out.println("Stack is not null");
NBTTagCompound tags = inputStack.getTagCompound().copy(); if (inputStack.hasTagCompound()) {
if(inputStackItem != null) { System.out.println("Stack Has NBT");
if (getModifiers(inputStack) < WeaponNBT.materialModifiers.get(((WeaponPart) outputStack.getItem()).getMaterial()) ) { if (getModifiers(inputStack) < WeaponNBT.materialModifiers.get(((WeaponPart) outputStack.getItem()).getMaterial()) ) {
if (RecipeHelper.isOreName(modStack, "dustSilver")) { if (RecipeHelper.isOreName(modStack, "dustSilver")) {
setSmiteLevel(outputStack, getSmiteLevel(inputStack) + 1); setSmiteLevel(outputStack, getSmiteLevel(inputStack) + 1);
setModifiers(outputStack, getModifiers(inputStack) + 1); setModifiers(outputStack, getModifiers(inputStack) + 1);
} }
if (RecipeHelper.isOreName(modStack, "foodPoison")) { if (RecipeHelper.isOreName(modStack, "foodPoison")) {
setBaneLevel(outputStack, getBaneLevel(inputStack) + 1); setBaneLevel(outputStack, getBaneLevel(inputStack) + 1);
setModifiers(outputStack, getModifiers(inputStack) + 1); setModifiers(outputStack, getModifiers(inputStack) + 1);
} }
if (RecipeHelper.isOreName(modStack, "dustBlaze")) { if (RecipeHelper.isOreName(modStack, "dustBlaze")) {
setFireLevel(outputStack, getFireLevel(inputStack) + 1); setFireLevel(outputStack, getFireLevel(inputStack) + 1);
setModifiers(outputStack, getModifiers(inputStack) + 1); setModifiers(outputStack, getModifiers(inputStack) + 1);
} }
if (RecipeHelper.isOreName(modStack, "gemLapis")) { if (RecipeHelper.isOreName(modStack, "gemLapis")) {
setFortuneLevel(outputStack, getFortuneLevel(inputStack) + 1); System.out.println("We are doign Gem Lapis Things");
setModifiers(outputStack, getModifiers(inputStack) + 1); 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);
}
} }
} }
} }

View File

@@ -34,6 +34,8 @@ import nmd.primal.forgecraft.tiles.TileNBTCrucible;
import java.util.Random; import java.util.Random;
import static net.minecraft.util.EnumHand.MAIN_HAND;
/** /**
* Created by mminaie on 11/11/17. * 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) { 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 (!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(); ItemStack pItem = player.inventory.getCurrentItem().copy();
pItem.setCount(1); pItem.setCount(1);
@@ -76,11 +84,15 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
return true; 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 (!player.isSneaking()) {
if (!pItem.isEmpty()) { 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) { if (pItem.getItem() instanceof SlottedTongs) {
return false; return false;
} else { } else {
@@ -101,10 +113,13 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
} }
} }
} }
}
/**CLEARS THE INVENTORY**/ /**CLEARS THE INVENTORY**/
if(hand.equals(MAIN_HAND)) {
if (player.isSneaking()) { if (player.isSneaking()) {
ItemStack pItem = player.inventory.getCurrentItem().copy();
if (pItem.isEmpty()) { if (pItem.isEmpty()) {
if (tile.getHot()!=15) { if (tile.getHot() != 15) {
if (!tile.getStatus()) { if (!tile.getStatus()) {
for (int i = 0; i < tile.ingList.size(); i++) { for (int i = 0; i < tile.ingList.size(); i++) {
if (!tile.ingList.get(i).isEmpty()) { if (!tile.ingList.get(i).isEmpty()) {
@@ -122,10 +137,13 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
} }
} }
} }
}
/**REMOVE COOKED ITEM**/ /**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 (pItem.isEmpty()) {
if (tile.getStatus() && tile.getHot()==6) { if (tile.getStatus() && tile.getHot() == 6) {
ItemStack dropStack = tile.getDrops().copy(); ItemStack dropStack = tile.getDrops().copy();
world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2); world.setBlockState(pos, state.withProperty(PrimalAPI.States.LAYERS, 0), 2);
tile.setHot(0); tile.setHot(0);
@@ -142,7 +160,6 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
} }
} }
} }
return true;
} }
} }
return false; return false;

View File

@@ -12,9 +12,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
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.core.common.helper.RecipeHelper;
import nmd.primal.core.common.items.tools.Gallagher; import nmd.primal.core.common.items.tools.Gallagher;
import nmd.primal.forgecraft.blocks.CustomContainerFacing; import nmd.primal.forgecraft.blocks.CustomContainerFacing;
import nmd.primal.forgecraft.crafting.WorkbenchCrafting; 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 nmd.primal.forgecraft.tiles.TileWorkbench;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@@ -92,8 +95,8 @@ public class Workbench extends CustomContainerFacing {
} }
if(playerStack.getItem() instanceof Gallagher) { if(playerStack.getItem() instanceof Gallagher) {
if (!slot2.isEmpty() && !slot3.isEmpty() && !slot4.isEmpty() && slot5.isEmpty()) { if (!slot2.isEmpty() && !slot3.isEmpty() && !slot4.isEmpty() && slot5.isEmpty()) {
WorkbenchCrafting recipe = WorkbenchCrafting.getRecipe(slot2, slot3, slot4, slot5); WorkbenchCrafting recipe = WorkbenchCrafting.getRecipe(slot2, slot3, slot4, slot5);
System.out.println(slot5);
if (recipe != null) { if (recipe != null) {
ItemStack drops = recipe.getOutput(); ItemStack drops = recipe.getOutput();
if (slot3.hasTagCompound()) { if (slot3.hasTagCompound()) {

View File

@@ -4,6 +4,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient; import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistry;
import nmd.primal.core.common.helper.RecipeHelper;
import nmd.primal.core.common.recipes.AbstractRecipe; import nmd.primal.core.common.recipes.AbstractRecipe;
import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.ModInfo;
@@ -102,17 +103,16 @@ public class WorkbenchCrafting extends AbstractRecipe<WorkbenchCrafting> { //ext
if(ingredient == null && stack.isEmpty()) { if(ingredient == null && stack.isEmpty()) {
return true; return true;
} }
if (ingredient.test(ItemStack.EMPTY)) { if (ingredient.test(ItemStack.EMPTY)) {
if (stack.isEmpty()) { if (stack.isEmpty()) {
return true; return true;
} }
} }
ItemStack[] testArray = ingredient.getMatchingStacks();
if(ingredient.apply(stack)){ List<ItemStack> testList = RecipeHelper.buildList(testArray);
if(testList.contains(stack)){
return true; return true;
} }
return false; return false;
} }

View File

@@ -380,8 +380,8 @@ public final class RecipesWorkbench {
recipes.register (new WorkbenchCrafting( recipes.register (new WorkbenchCrafting(
new OreIngredient("weaponHandle"), new OreIngredient("weaponHandle"),
new OreIngredient("weaponGuard"),
Ingredient.fromStacks(new ItemStack(ModItems.rawbronzegladius, 1)), Ingredient.fromStacks(new ItemStack(ModItems.rawbronzegladius, 1)),
new OreIngredient("weaponGuard"),
Ingredient.EMPTY, Ingredient.EMPTY,
new ItemStack(ModItems.bronzegladius, 1)).setRecipeName("bronzegladius")); new ItemStack(ModItems.bronzegladius, 1)).setRecipeName("bronzegladius"));

View File

@@ -118,24 +118,24 @@ public class WeaponPart extends Item implements WeaponNBT {
if(stack.hasTagCompound()) { if(stack.hasTagCompound()) {
if (stack.getSubCompound("tags") != null) { if (stack.getSubCompound("tags") != null) {
tooltip.add(ChatFormatting.GRAY + "Upgrades left: " + (WeaponNBT.materialModifiers.get(this.toolMaterial) - getModifiers(stack))); tooltip.add(ChatFormatting.GRAY + "Upgrades left: " + (WeaponNBT.materialModifiers.get(this.toolMaterial) - getModifiers(stack)));
} if (getSmiteLevel(stack) > 0) {
if (getSmiteLevel(stack) > 0) { tooltip.add(ChatFormatting.GOLD + "Holy: " + getSmiteLevel(stack));
tooltip.add(ChatFormatting.GOLD + "Holy: " + getSmiteLevel(stack)); }
} if (getBaneLevel(stack) > 0) {
if (getBaneLevel(stack) > 0) { tooltip.add(ChatFormatting.GREEN + "Spider Killing: " + getBaneLevel(stack));
tooltip.add(ChatFormatting.GREEN + "Spider Killing: " + getBaneLevel(stack)); }
} if (getFireLevel(stack) > 0) {
if (getFireLevel(stack) > 0) { tooltip.add(ChatFormatting.RED + "Flame: " + getFireLevel(stack));
tooltip.add(ChatFormatting.RED + "Flame: " + getFireLevel(stack)); }
} if (getFortuneLevel(stack) > 0) {
if (getFortuneLevel(stack) > 0) { tooltip.add(ChatFormatting.BLUE + "Thieving: " + getFortuneLevel(stack));
tooltip.add(ChatFormatting.BLUE + "Thieving: " + getFortuneLevel(stack)); }
} if (getLeechLevel(stack) > 0) {
if (getLeechLevel(stack) > 0) { tooltip.add(ChatFormatting.BLACK + "Life Steal: " + getLeechLevel(stack));
tooltip.add(ChatFormatting.BLACK + "Life Steal: " + getLeechLevel(stack)); }
} if (getSharpnessLevel(stack) > 0) {
if(getSharpnessLevel(stack)>0){ tooltip.add(ChatFormatting.WHITE + "Sharpness: " + getSharpnessLevel(stack));
tooltip.add(ChatFormatting.WHITE + "Sharpness: " + getSharpnessLevel(stack)); }
} }
} }
} }

View File

@@ -16,6 +16,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import nmd.primal.forgecraft.ModInfo; import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.util.WeaponNBT;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
@@ -23,11 +24,11 @@ import java.util.List;
/** /**
* Created by mminaie on 3/23/17. * Created by mminaie on 3/23/17.
*/ */
public class CustomSword extends ItemSword { public class CustomSword extends ItemSword implements WeaponNBT {
private double attack, speed; private double attack, speed;
private ToolMaterial toolMaterial;
public CustomSword(String name, Item.ToolMaterial material, double attackDamage, double attackSpeed) { public CustomSword(String name, ToolMaterial material, double attackDamage, double attackSpeed) {
super(material); super(material);
this.setUnlocalizedName(name); this.setUnlocalizedName(name);
this.setRegistryName(name); this.setRegistryName(name);
@@ -36,7 +37,7 @@ public class CustomSword extends ItemSword {
this.setNoRepair(); this.setNoRepair();
this.attack = attackDamage; this.attack = attackDamage;
this.speed = attackSpeed; this.speed = attackSpeed;
this.toolMaterial= material;
} }
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@@ -79,13 +80,30 @@ public class CustomSword extends ItemSword {
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public void addInformation(ItemStack item, @Nullable World world, List<String> tooltip, ITooltipFlag flagIn) public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flagIn)
{ {
//tooltip.add(ChatFormatting.GRAY + "Damage: " + item.getItemDamage() ); //tooltip.add(ChatFormatting.GRAY + "Damage: " + item.getItemDamage() );
if(item.hasTagCompound()) if(stack.hasTagCompound())
{ {
tooltip.add(ChatFormatting.GRAY + "Upgrades: " ); tooltip.add(ChatFormatting.GRAY + "Upgrades left: " + (WeaponNBT.materialModifiers.get(this.toolMaterial) - getModifiers(stack)));
tooltip.add(ChatFormatting.LIGHT_PURPLE + "Damage: " + item.getItemDamage() ); 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));
}
} }
} }

View File

@@ -40,13 +40,12 @@ public class TileWorkbench extends TileBaseSlot{
} }
}*/ }*/
if(index == 3){ if(index == 3){
if ( (stack.getItem() instanceof ToolPart) || stack.getItem() instanceof WeaponGuard) { if ( (stack.getItem() instanceof ToolPart) || stack.getItem() instanceof WeaponPart) {
return true; return true;
} }
} }
if(index == 4){ if(index == 4){
if ( (RecipeHelper.isOreName(stack.getItem(), "pinBasic")) || if ( (RecipeHelper.isOreName(stack.getItem(), "pinBasic")) || stack.getItem() instanceof WeaponGuard) {
stack.getItem() instanceof WeaponPart) {
return true; return true;
} }
} }