Advertisement
Guest User

Muramasa

a guest
Dec 20th, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.79 KB | None | 0 0
  1. package com.github.elrol.SwordsOfLegend.items;
  2.  
  3. import java.util.List;
  4.  
  5. import javax.annotation.Nullable;
  6.  
  7. import com.github.elrol.SwordsOfLegend.SwordsOfLegend;
  8. import com.github.elrol.SwordsOfLegend.config.ConfigManager;
  9. import com.github.elrol.SwordsOfLegend.materials.ToolMaterials;
  10. import com.google.common.collect.Multimap;
  11.  
  12. import net.minecraft.client.util.ITooltipFlag;
  13. import net.minecraft.creativetab.CreativeTabs;
  14. import net.minecraft.entity.Entity;
  15. import net.minecraft.entity.SharedMonsterAttributes;
  16. import net.minecraft.entity.ai.attributes.AttributeModifier;
  17. import net.minecraft.inventory.EntityEquipmentSlot;
  18. import net.minecraft.item.ItemStack;
  19. import net.minecraft.item.ItemSword;
  20. import net.minecraft.nbt.NBTTagCompound;
  21. import net.minecraft.world.World;
  22.  
  23. public class Muramasa extends ItemSword{
  24.  
  25.     protected String name = "muramasa";
  26.     protected double souls;
  27.     double attackMod = this.souls > 0 ? (double)(this.souls / (double)ConfigManager.soulsPerDamage) : 0D;
  28.     double speedMod = this.souls > 0 ? (double)(this.souls / (double)ConfigManager.soulsPerSpeed) : 0D;
  29.    
  30.     public Muramasa() {
  31.         super(ToolMaterials.muramasa);
  32.         setUnlocalizedName(name);
  33.         setRegistryName(name);
  34.     }
  35.  
  36.     public void registerItemModel() {
  37.         SwordsOfLegend.proxy.registerItemRenderer(this, 0, name);
  38.     }
  39.  
  40.     @Override
  41.     public Muramasa setCreativeTab(CreativeTabs tab) {
  42.         super.setCreativeTab(tab);
  43.         return this;
  44.     }
  45.    
  46.     @Override
  47.     public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot){
  48.         Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
  49.         if (equipmentSlot == EntityEquipmentSlot.MAINHAND){
  50.             multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double)super.getAttackDamage() + 100, 0));
  51.             multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D + speedMod, 0));
  52.         }
  53.  
  54.         return multimap;
  55.     }
  56.    
  57.     @Override
  58.     public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) {
  59.         //Update nbt data
  60.         if(itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("souls")) {
  61.             this.souls = itemStack.getTagCompound().getInteger("souls");
  62.         } else {
  63.             itemStack.setTagCompound(new NBTTagCompound());
  64.             itemStack.getTagCompound().setInteger("souls", 0);
  65.         }
  66.        
  67.     }
  68.    
  69.     @Override
  70.     public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn){
  71.         if(stack.hasTagCompound() && stack.getTagCompound().hasKey("souls")) {
  72.             tooltip.add("Souls: " + stack.getTagCompound().getInteger("souls"));
  73.         }
  74.     }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement