fixed tool NBT crashing when returning null nbt
This commit is contained in:
@@ -9,9 +9,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||||||
public interface ToolNBT {
|
public interface ToolNBT {
|
||||||
|
|
||||||
default boolean getHot(ItemStack stack){
|
default boolean getHot(ItemStack stack){
|
||||||
|
if(!stack.isEmpty()) {
|
||||||
if (stack.hasTagCompound()) {
|
if (stack.hasTagCompound()) {
|
||||||
|
if (stack.getSubCompound("tags") != null) {
|
||||||
return stack.getSubCompound("tags").getBoolean("hot");
|
return stack.getSubCompound("tags").getBoolean("hot");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default void setHot(ItemStack stack, Boolean bool){
|
default void setHot(ItemStack stack, Boolean bool){
|
||||||
@@ -19,9 +23,13 @@ public interface ToolNBT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default int getModifiers(ItemStack stack) {
|
default int getModifiers(ItemStack stack) {
|
||||||
|
if(!stack.isEmpty()) {
|
||||||
if (stack.hasTagCompound()) {
|
if (stack.hasTagCompound()) {
|
||||||
|
if (stack.getSubCompound("tags") != null) {
|
||||||
return stack.getSubCompound("tags").getInteger("modifiers");
|
return stack.getSubCompound("tags").getInteger("modifiers");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
default void setModifiers(ItemStack stack, Integer mods){
|
default void setModifiers(ItemStack stack, Integer mods){
|
||||||
@@ -29,15 +37,29 @@ public interface ToolNBT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default boolean getEmerald(ItemStack stack){
|
default boolean getEmerald(ItemStack stack){
|
||||||
|
if(!stack.isEmpty()) {
|
||||||
|
if (stack.hasTagCompound()) {
|
||||||
|
if (stack.getSubCompound("tags") != null) {
|
||||||
return stack.getSubCompound("tags").getBoolean("emerald");
|
return stack.getSubCompound("tags").getBoolean("emerald");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
default void setEmerald(ItemStack stack, Boolean bool){
|
default void setEmerald(ItemStack stack, Boolean bool){
|
||||||
stack.getSubCompound("tags").setBoolean("emerald", bool);
|
stack.getSubCompound("tags").setBoolean("emerald", bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int getDiamondLevel(ItemStack stack) {
|
default int getDiamondLevel(ItemStack stack) {
|
||||||
|
if(!stack.isEmpty()) {
|
||||||
|
if (stack.hasTagCompound()) {
|
||||||
|
if (stack.getSubCompound("tags") != null) {
|
||||||
return stack.getSubCompound("tags").getInteger("diamond");
|
return stack.getSubCompound("tags").getInteger("diamond");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
default void setDiamondLevel(ItemStack stack, Integer level){
|
default void setDiamondLevel(ItemStack stack, Integer level){
|
||||||
stack.getSubCompound("tags").setInteger("diamond", level);
|
stack.getSubCompound("tags").setInteger("diamond", level);
|
||||||
@@ -45,21 +67,42 @@ public interface ToolNBT {
|
|||||||
|
|
||||||
|
|
||||||
default int getRedstoneLevel(ItemStack stack) {
|
default int getRedstoneLevel(ItemStack stack) {
|
||||||
|
if(!stack.isEmpty()) {
|
||||||
|
if (stack.hasTagCompound()) {
|
||||||
|
if (stack.getSubCompound("tags") != null) {
|
||||||
return stack.getSubCompound("tags").getInteger("redstone");
|
return stack.getSubCompound("tags").getInteger("redstone");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
default void setRedstoneLevel(ItemStack stack, Integer level){
|
default void setRedstoneLevel(ItemStack stack, Integer level){
|
||||||
stack.getSubCompound("tags").setInteger("redstone", level);
|
stack.getSubCompound("tags").setInteger("redstone", level);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int getLapisLevel(ItemStack stack) {
|
default int getLapisLevel(ItemStack stack) {
|
||||||
|
if(!stack.isEmpty()) {
|
||||||
|
if (stack.hasTagCompound()) {
|
||||||
|
if (stack.getSubCompound("tags") != null) {
|
||||||
return stack.getSubCompound("tags").getInteger("lapis");
|
return stack.getSubCompound("tags").getInteger("lapis");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
default void setLapisLevel(ItemStack stack, Integer level){
|
default void setLapisLevel(ItemStack stack, Integer level){
|
||||||
stack.getSubCompound("tags").setInteger("lapis", level);
|
stack.getSubCompound("tags").setInteger("lapis", level);
|
||||||
}
|
}
|
||||||
|
|
||||||
default NBTTagCompound getTags(ItemStack stack){
|
default NBTTagCompound getTags(ItemStack stack){
|
||||||
|
if(!stack.isEmpty()) {
|
||||||
|
if (stack.hasTagCompound()) {
|
||||||
|
if (stack.getSubCompound("tags") != null) {
|
||||||
return stack.getSubCompound("tags");
|
return stack.getSubCompound("tags");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ public class ItemStoneTongs extends Item {
|
|||||||
//System.out.println(itemstack.getTagCompound().getInteger("type"));
|
//System.out.println(itemstack.getTagCompound().getInteger("type"));
|
||||||
}
|
}
|
||||||
//System.out.println(player.getHeldItem(hand).getTagCompound().getInteger("type"));
|
//System.out.println(player.getHeldItem(hand).getTagCompound().getInteger("type"));
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.FAIL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
|
|||||||
public float apply(ItemStack item, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
|
public float apply(ItemStack item, @Nullable World worldIn, @Nullable EntityLivingBase entityIn) {
|
||||||
if (item.hasTagCompound()) {
|
if (item.hasTagCompound()) {
|
||||||
|
|
||||||
if (getHot(item) == false) {
|
|
||||||
|
|
||||||
|
if (getHot(item) != true) {
|
||||||
if (getModifiers(item) != 0) {
|
if (getModifiers(item) != 0) {
|
||||||
if ((getEmerald(item) == true) &&
|
if ((getEmerald(item) == true) &&
|
||||||
(getDiamondLevel(item) == 0) &&
|
(getDiamondLevel(item) == 0) &&
|
||||||
@@ -204,10 +206,11 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getHot(item) == false) {
|
if (getHot(item) == false) {
|
||||||
if (item.getSubCompound("tags").getInteger("modifiers") == 0) {
|
if (getModifiers(item) == 0) {
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
@@ -268,27 +271,27 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void addInformation(ItemStack item, EntityPlayer player, List<String> tooltip, boolean advanced)
|
public void addInformation(ItemStack item, EntityPlayer player, List<String> tooltip, boolean advanced)
|
||||||
{
|
{
|
||||||
|
if(!item.isEmpty()) {
|
||||||
if (player.getEntityWorld().isRemote) {
|
if (player.getEntityWorld().isRemote) {
|
||||||
|
|
||||||
if (item.hasTagCompound()) {
|
if (item.hasTagCompound()) {
|
||||||
|
|
||||||
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
||||||
if (item.getSubCompound("tags").getBoolean("emerald") == true) {
|
if (getEmerald(item) == true) {
|
||||||
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("diamond") > 0) {
|
if (getDiamondLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("redstone") > 0) {
|
if (getRedstoneLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("lapis") > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -296,7 +299,7 @@ public class CustomAxe extends ItemAxe implements ToolNBT {
|
|||||||
{
|
{
|
||||||
if(!player.world.isRemote){
|
if(!player.world.isRemote){
|
||||||
World world = player.getEntityWorld();
|
World world = player.getEntityWorld();
|
||||||
System.out.println(world.getBlockState(pos).getBlock());
|
//System.out.println(world.getBlockState(pos).getBlock());
|
||||||
if(itemstack.getItem() instanceof CustomPickaxe){
|
if(itemstack.getItem() instanceof CustomPickaxe){
|
||||||
if( getEmerald(itemstack)){
|
if( getEmerald(itemstack)){
|
||||||
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
itemstack.addEnchantment(Enchantment.getEnchantmentByID(33), 1);
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getHot(item) == false) {
|
if (getHot(item) == false) {
|
||||||
if (item.getSubCompound("tags").getInteger("modifiers") == 0) {
|
if (getModifiers(item) == 0) {
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,16 +273,16 @@ public class CustomHoe extends ItemHoe implements ToolNBT {
|
|||||||
if(item.hasTagCompound()) {
|
if(item.hasTagCompound()) {
|
||||||
|
|
||||||
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
||||||
if (item.getSubCompound("tags").getBoolean("emerald") == true) {
|
if (getEmerald(item) == true) {
|
||||||
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("diamond") > 0) {
|
if (getDiamondLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("redstone") > 0) {
|
if (getRedstoneLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("lapis") > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getHot(item) == false) {
|
if (getHot(item) == false) {
|
||||||
if (item.getSubCompound("tags").getInteger("modifiers") == 0) {
|
if (getModifiers(item) == 0) {
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,16 +280,16 @@ public class CustomPickaxe extends ItemPickaxe implements ToolNBT{
|
|||||||
if(item.hasTagCompound()) {
|
if(item.hasTagCompound()) {
|
||||||
|
|
||||||
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
||||||
if (item.getSubCompound("tags").getBoolean("emerald") == true) {
|
if (getEmerald(item) == true) {
|
||||||
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("diamond") > 0) {
|
if (getDiamondLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("redstone") > 0) {
|
if (getRedstoneLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("lapis") > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getHot(item) == false) {
|
if (getHot(item) == false) {
|
||||||
if (item.getSubCompound("tags").getInteger("modifiers") == 0) {
|
if (getModifiers(item) == 0) {
|
||||||
return 0.0F;
|
return 0.0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,16 +273,16 @@ public class CustomShovel extends ItemSpade implements ToolNBT {
|
|||||||
if(item.hasTagCompound()) {
|
if(item.hasTagCompound()) {
|
||||||
|
|
||||||
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
tooltip.add(ChatFormatting.GRAY + "Upgrades Left: " + (3 - getModifiers(item)) );
|
||||||
if (item.getSubCompound("tags").getBoolean("emerald") == true) {
|
if (getEmerald(item) == true) {
|
||||||
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
tooltip.add(ChatFormatting.DARK_GREEN + "Emerald");
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("diamond") > 0) {
|
if (getDiamondLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
tooltip.add(ChatFormatting.AQUA + "Diamond Level: " + getDiamondLevel(item));
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("redstone") > 0) {
|
if (getRedstoneLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
tooltip.add(ChatFormatting.RED + "Redstone Level: " + getRedstoneLevel(item) );
|
||||||
}
|
}
|
||||||
if (item.getSubCompound("tags").getInteger("lapis") > 0) {
|
if (getLapisLevel(item) > 0) {
|
||||||
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
tooltip.add(ChatFormatting.BLUE + "Lapis Level: " + getLapisLevel(item) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ itemGroup.forgecraft=ForgeCraft
|
|||||||
|
|
||||||
tile.firebox.name=Forge
|
tile.firebox.name=Forge
|
||||||
tile.bloomery.name=Bloomery
|
tile.bloomery.name=Bloomery
|
||||||
|
tile.stoneanvil.name=Stone Anvil
|
||||||
tile.pistonbellows.name=Wooden Piston Bellows
|
tile.pistonbellows.name=Wooden Piston Bellows
|
||||||
tile.emptycrucible.name=Empty Crucible
|
tile.emptycrucible.name=Empty Crucible
|
||||||
tile.emptycruciblehit.name=Hot Empty Crucible
|
tile.emptycruciblehit.name=Hot Empty Crucible
|
||||||
|
|||||||
Reference in New Issue
Block a user