Advertisement
Guest User

Untitled

a guest
Jun 21st, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. public class Shield extends ItemShield {
  2.  
  3. public String name;
  4. public CreativeTabs tab;
  5.  
  6. public Shield(int durability, String name, CreativeTabs tab) {
  7. this.setMaxDamage(durability);
  8. this.name = name;
  9. this.tab = tab;
  10. this.addPropertyOverride(new ResourceLocation("blocking"), new IItemPropertyGetter() {
  11. @SideOnly(Side.CLIENT)
  12. public float apply(ItemStack stack, World worldIn, EntityLivingBase entityIn) {
  13. return entityIn != null && entityIn.isHandActive() && entityIn.getActiveItemStack() == stack ? 1.0F
  14. : 0.0F;
  15. }
  16. });
  17. this.setCreativeTab(tab);
  18. }
  19.  
  20. @Override
  21. public String getItemStackDisplayName(ItemStack stack) {
  22. return I18n.translateToLocal("item." + name + ".name");
  23. }
  24.  
  25. @Override
  26. @SideOnly(Side.CLIENT)
  27. public CreativeTabs getCreativeTab() {
  28. return tab;
  29. }
  30.  
  31. @Override
  32. public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn,
  33. EnumHand hand) {
  34. playerIn.setActiveHand(hand);
  35. if (playerIn.isCollided) {
  36. itemStackIn.damageItem(1, playerIn);
  37. }
  38. return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement