Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.github.elrol.SwordsOfLegend.items;
- import java.util.List;
- import javax.annotation.Nullable;
- import com.github.elrol.SwordsOfLegend.SwordsOfLegend;
- import com.github.elrol.SwordsOfLegend.config.ConfigManager;
- import com.github.elrol.SwordsOfLegend.materials.ToolMaterials;
- import com.google.common.collect.Multimap;
- import net.minecraft.client.util.ITooltipFlag;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.SharedMonsterAttributes;
- import net.minecraft.entity.ai.attributes.AttributeModifier;
- import net.minecraft.inventory.EntityEquipmentSlot;
- import net.minecraft.item.ItemStack;
- import net.minecraft.item.ItemSword;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.world.World;
- public class Muramasa extends ItemSword{
- protected String name = "muramasa";
- protected double souls;
- double attackMod = this.souls > 0 ? (double)(this.souls / (double)ConfigManager.soulsPerDamage) : 0D;
- double speedMod = this.souls > 0 ? (double)(this.souls / (double)ConfigManager.soulsPerSpeed) : 0D;
- public Muramasa() {
- super(ToolMaterials.muramasa);
- setUnlocalizedName(name);
- setRegistryName(name);
- }
- public void registerItemModel() {
- SwordsOfLegend.proxy.registerItemRenderer(this, 0, name);
- }
- @Override
- public Muramasa setCreativeTab(CreativeTabs tab) {
- super.setCreativeTab(tab);
- return this;
- }
- @Override
- public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot){
- Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
- if (equipmentSlot == EntityEquipmentSlot.MAINHAND){
- multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", (double)super.getAttackDamage() + 100, 0));
- multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.4000000953674316D + speedMod, 0));
- }
- return multimap;
- }
- @Override
- public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5) {
- //Update nbt data
- if(itemStack.hasTagCompound() && itemStack.getTagCompound().hasKey("souls")) {
- this.souls = itemStack.getTagCompound().getInteger("souls");
- } else {
- itemStack.setTagCompound(new NBTTagCompound());
- itemStack.getTagCompound().setInteger("souls", 0);
- }
- }
- @Override
- public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn){
- if(stack.hasTagCompound() && stack.getTagCompound().hasKey("souls")) {
- tooltip.add("Souls: " + stack.getTagCompound().getInteger("souls"));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement