fixed bug with jei crashing when hovering over tool or weapon parts

This commit is contained in:
Mohammad-Ali Minaie
2019-06-09 15:09:33 -04:00
parent bad57bdb6b
commit cbe15662e3
3 changed files with 28 additions and 3 deletions

View File

@@ -69,7 +69,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
/**PICKS UP THE CRUCIBLE**/
if (playerStackStart.isEmpty()) {
if (!player.isSneaking()) {
System.out.println(tile.getHot());
//System.out.println(tile.getHot());
CrucibleCrafting recipe = CrucibleCrafting.getRecipe(tile.ingList.get(0), tile.ingList.get(1), tile.ingList.get(2), tile.ingList.get(3), tile.ingList.get(4));
if (recipe != null) {
@@ -80,7 +80,7 @@ public class NBTCrucible extends BlockContainer implements ITileEntityProvider {
//ItemHandlerHelper.giveItemToPlayer(player, this.getCrucibleItem(world, pos, state, player));
world.setBlockState(pos, this.getReplacementBlock(world, pos, state));
world.markTileEntityForRemoval(tile);
System.out.println(player.getHeldItemMainhand().getTagCompound());
//System.out.println(player.getHeldItemMainhand().getTagCompound());
return true;
}
}

View File

@@ -7,10 +7,15 @@ import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import nmd.primal.core.common.helper.CommonUtils;
import nmd.primal.forgecraft.ModInfo;
import nmd.primal.forgecraft.compat.jei.AbstractCategory;
import nmd.primal.forgecraft.items.parts.ToolPart;
import nmd.primal.forgecraft.items.parts.WeaponPart;
import nmd.primal.forgecraft.util.ToolNBT;
import nmd.primal.forgecraft.util.WeaponNBT;
import javax.annotation.Nonnull;
@@ -101,7 +106,16 @@ public class CastingRecipeCategory extends AbstractCategory<CastingRecipeWrapper
/***OUTPUTS***/
items.init(26, false, 133, 77);
items.set(26, recipe.output);
if(recipe.output.getItem() instanceof WeaponPart){
ItemStack tempStack = new ItemStack(recipe.output.getItem(), 1);
WeaponNBT.setDefaultNBT(tempStack);
items.set(26, tempStack);
} else if(recipe.output.getItem() instanceof ToolPart){
ItemStack tempStack = new ItemStack(recipe.output.getItem(), 1);
ToolNBT.setDefaultNBT(tempStack);
items.set(26, tempStack);
} else {items.set(26, recipe.output);}
/***EXTRAS***/
//items.init(26, false, 105, 28);

View File

@@ -105,4 +105,15 @@ public interface ToolNBT {
return null;
}
static void setDefaultNBT(ItemStack stack) {
stack.getOrCreateSubCompound("tags");
stack.getSubCompound("tags").setBoolean("hot", false);
stack.getSubCompound("tags").setBoolean("emerald", false);
stack.getSubCompound("tags").setInteger("diamond", 0);
stack.getSubCompound("tags").setInteger("redstone", 0);
stack.getSubCompound("tags").setInteger("lapis", 0);
stack.getSubCompound("tags").setInteger("modifiers", 0);
}
}