Bound tools should be unbreakable, yet enchantable (#815, #793)

This commit is contained in:
Nicholas Ignoffo 2016-06-23 18:40:28 -07:00
parent d240daf958
commit aeb7b0af12
4 changed files with 31 additions and 4 deletions

View file

@ -5,13 +5,16 @@ import java.util.List;
import javax.annotation.Nullable;
import WayofTime.bloodmagic.util.Utils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.util.ActionResult;
@ -83,6 +86,12 @@ public class ItemBoundSword extends ItemSword implements IBindable, IActivatable
return oldStack.getItem() != newStack.getItem();
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
subItems.add(Utils.setUnbreakable(new ItemStack(itemIn)));
}
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced)

View file

@ -7,12 +7,14 @@ import java.util.Set;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
import WayofTime.bloodmagic.util.Utils;
import com.google.common.base.Strings;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import lombok.Getter;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AttributeModifier;
@ -20,8 +22,10 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
@ -75,6 +79,12 @@ public class ItemBoundTool extends ItemTool implements IBindable, IActivatable
return slotChanged;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
subItems.add(Utils.setUnbreakable(new ItemStack(itemIn)));
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected)
{

View file

@ -3,6 +3,7 @@ package WayofTime.bloodmagic.registry;
import java.util.ArrayList;
import java.util.List;
import WayofTime.bloodmagic.util.Utils;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@ -193,10 +194,10 @@ public class ModRecipes
public static void addAlchemyArrayRecipes()
{
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_SWORD), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundSword)), new BindingAlchemyCircleRenderer());
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_AXE), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundAxe)));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_PICKAXE), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundPickaxe)));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_SHOVEL), new AlchemyArrayEffectBinding(new ItemStack(ModItems.boundShovel)));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_SWORD), new AlchemyArrayEffectBinding(Utils.setUnbreakable(new ItemStack(ModItems.boundSword))), new BindingAlchemyCircleRenderer());
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_AXE), new AlchemyArrayEffectBinding(Utils.setUnbreakable(new ItemStack(ModItems.boundAxe))));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_PICKAXE), new AlchemyArrayEffectBinding(Utils.setUnbreakable(new ItemStack(ModItems.boundPickaxe))));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.DIAMOND_SHOVEL), new AlchemyArrayEffectBinding(Utils.setUnbreakable(new ItemStack(ModItems.boundShovel))));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.IRON_HELMET), new AlchemyArrayEffectBinding(new ItemStack(ModItems.livingArmourHelmet)));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.IRON_CHESTPLATE), new AlchemyArrayEffectBinding(new ItemStack(ModItems.livingArmourChest)));
AlchemyArrayRecipeRegistry.registerRecipe(ItemComponent.getStack(ItemComponent.REAGENT_BINDING), new ItemStack(Items.IRON_LEGGINGS), new AlchemyArrayEffectBinding(new ItemStack(ModItems.livingArmourLegs)));

View file

@ -5,6 +5,7 @@ import java.util.Locale;
import java.util.Set;
import WayofTime.bloodmagic.BloodMagic;
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockPortal;
import net.minecraft.block.state.IBlockState;
@ -172,6 +173,12 @@ public class Utils
return itemHandler;
}
public static ItemStack setUnbreakable(ItemStack stack) {
NBTHelper.checkNBT(stack);
stack.getTagCompound().setBoolean("Unbreakable", true);
return stack;
}
/**
* Gets a default block for each type of {@link EnumAltarComponent}
*