net.minecraft.entity.ai.attributes.AttributeModifier Java Examples

The following examples show how to use net.minecraft.entity.ai.attributes.AttributeModifier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ComponentNormalDamage.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public ItemStack attached(ItemStack i, Random rand, int[] eff) {
	NBTTagCompound inbt = i.stackTagCompound;
	NBTTagCompound nnbt = new NBTTagCompound();
	NBTTagList nnbtl = new NBTTagList();
	int base = i.stackTagCompound.getInteger("material");
	switch(base) {
		case 0:
		case 3:
			base = 0;
			break;
	}
	base += 4;
	AttributeModifier att = new AttributeModifier("generic.attackDamage", base, 0);
	nnbt.setLong("UUIDMost", att.getID().getMostSignificantBits());
	nnbt.setLong("UUIDLeast", att.getID().getLeastSignificantBits());
	nnbt.setString("Name", att.getName());
	nnbt.setDouble("Amount", att.getAmount());
	nnbt.setInteger("Operation", att.getOperation());
	nnbt.setString("AttributeName", att.getName());
	nnbtl.appendTag(nnbt);
	inbt.setTag("AttributeModifiers", nnbtl);
	//i.addEnchantment(Enchantment.sharpness, rand.nextInt(5)+1);
	return i;
}
 
Example #2
Source File: ComponentDamage.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public ItemStack attached(ItemStack i, Random rand, int[] eff) {
	NBTTagCompound inbt = i.stackTagCompound;
	NBTTagCompound nnbt = new NBTTagCompound();
	NBTTagList nnbtl = new NBTTagList();
	int base = i.stackTagCompound.getInteger("material");
	switch(base) {
		case 0:
		case 3:
			base = 0;
			break;
	}
	base += 6;
	AttributeModifier att = new AttributeModifier("generic.attackDamage", rand.nextInt(5)+base, 0);
	nnbt.setLong("UUIDMost", att.getID().getMostSignificantBits());
	nnbt.setLong("UUIDLeast", att.getID().getLeastSignificantBits());
	nnbt.setString("Name", att.getName());
	nnbt.setDouble("Amount", att.getAmount());
	nnbt.setInteger("Operation", att.getOperation());
	nnbt.setString("AttributeName", att.getName());
	nnbtl.appendTag(nnbt);
	inbt.setTag("AttributeModifiers", nnbtl);
	//i.addEnchantment(Enchantment.sharpness, rand.nextInt(5)+1);
	return i;
}
 
Example #3
Source File: ComponentSpeed.java    From Artifacts with MIT License 6 votes vote down vote up
@Override
public ItemStack attached(ItemStack i, Random rand, int[] eff) {
	int q = i.stackTagCompound.getInteger("onHeld");
	if(q > 0) {
		IArtifactComponent a = ArtifactsAPI.artifacts.getComponent(q);
		if(a == this) {
			NBTTagCompound inbt = i.stackTagCompound;
			NBTTagCompound nnbt = new NBTTagCompound();
			NBTTagList nnbtl = new NBTTagList();
			double amount = 0.05D + rand.nextInt(5)/200D + rand.nextInt(5)/200D;
			i.stackTagCompound.setDouble("boostAmount",amount);
			AttributeModifier att = new AttributeModifier("generic.movementSpeed", amount, 2);
			nnbt.setLong("UUIDMost", att.getID().getMostSignificantBits());
			nnbt.setLong("UUIDLeast", att.getID().getLeastSignificantBits());
			nnbt.setString("Name", att.getName());
			nnbt.setDouble("Amount", att.getAmount());
			nnbt.setInteger("Operation", att.getOperation());
			nnbt.setString("AttributeName", att.getName());
			nnbtl.appendTag(nnbt);
			inbt.setTag("AttributeModifiers", nnbtl);
		}
	}
	return i;
}
 
Example #4
Source File: ArtifactTickHandler.java    From Artifacts with MIT License 6 votes vote down vote up
private void updateSpeedBoost(int artifactSpeedBoostCount, EntityPlayer player) {
	NBTTagCompound playerData = player.getEntityData();
	int oldSpeedBoostCount = playerData.getInteger("artifactSpeedBoostCount");
	
	if(oldSpeedBoostCount != artifactSpeedBoostCount) {
		String uu = playerData.getString("artifactSpeedBoostUUID");
		UUID speedID;
		
		if(uu.equals("")) {
			speedID = UUID.randomUUID();
			playerData.setString("artifactSpeedBoostUUID", speedID.toString());
		}
		else {
			speedID = UUID.fromString(uu);
		}
		
		IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
		
		atinst.removeModifier(new AttributeModifier(speedID, "SpeedBoostComponent", 0.05F * oldSpeedBoostCount, 2));
		atinst.applyModifier(new AttributeModifier(speedID, "SpeedBoostComponent", 0.05F * artifactSpeedBoostCount, 2));
		
		playerData.setInteger("artifactSpeedBoostCount", artifactSpeedBoostCount);
	}
}
 
Example #5
Source File: ArtifactTickHandler.java    From Artifacts with MIT License 6 votes vote down vote up
private void updateKnockbackResistance(int artifactKnockbackCount, EntityPlayer player) {
	NBTTagCompound playerData = player.getEntityData();
	int oldKnockbackCount = playerData.getInteger("artifactKnockbackCount");
	
	if(oldKnockbackCount != artifactKnockbackCount) {
		String uu = playerData.getString("artifactKnockbackUUID");
		UUID knockbackID;
		
		if(uu.equals("")) {
			knockbackID = UUID.randomUUID();
			playerData.setString("artifactKnockbackUUID", knockbackID.toString());
		}
		else {
			knockbackID = UUID.fromString(uu);
		}
		
		IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.knockbackResistance);
		
		atinst.removeModifier(new AttributeModifier(knockbackID, "KnockbackComponent", 0.2F * oldKnockbackCount, 0));
		atinst.applyModifier(new AttributeModifier(knockbackID, "KnockbackComponent", 0.2F * artifactKnockbackCount, 0));
		
		playerData.setInteger("artifactKnockbackCount", artifactKnockbackCount);
	}
}
 
Example #6
Source File: ToolMetaItem.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    T metaValueItem = getItem(stack);
    HashMultimap<String, AttributeModifier> modifiers = HashMultimap.create();
    modifiers.putAll(super.getAttributeModifiers(slot, stack));
    if (metaValueItem != null && slot == EntityEquipmentSlot.MAINHAND) {
        IToolStats toolStats = metaValueItem.getToolStats();
        if (toolStats == null) {
            return HashMultimap.create();
        }
        float attackDamage = getToolAttackDamage(stack);
        float attackSpeed = toolStats.getAttackSpeed(stack);

        modifiers.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", attackDamage, 0));
        modifiers.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", attackSpeed, 0));
    }
    return modifiers;
}
 
Example #7
Source File: ItemVoidPickaxe.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack)
{
    Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot, stack);
    double dmg = this.isToolBroken(stack) ? 0.5f : 6f; // Default to almost no damage if the tool is broken

    if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
    {
        String modifierName = "Tool modifier";

        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
                new AttributeModifier(ATTACK_DAMAGE_MODIFIER, modifierName, dmg, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
                new AttributeModifier(ATTACK_SPEED_MODIFIER, modifierName, -2.7f, 0));
    }

    return multimap;
}
 
Example #8
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
@Override
  public IEntityLivingData onInitialSpawn(DifficultyInstance di, IEntityLivingData livingData) {
    spawned = true;

    //From base entity living class
    getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random spawn bonus", rand.nextGaussian() * 0.05D, 1));
//    func_189768_a(SkeletonType.NORMAL);//skeleton types do not exist anymore in 1.11.2. so its always normal.
    addRandomArmor();
    setEnchantmentBasedOnDifficulty(di); //enchantEquipment();

    float f = di.getClampedAdditionalDifficulty();
    this.setCanPickUpLoot(this.rand.nextFloat() < 0.55F * f);
    setCanPickUpLoot(rand.nextFloat() < 0.55F * f);
    setCanBreakDoors(rand.nextFloat() < f * 0.1F);

    return livingData;
  }
 
Example #9
Source File: EntityCyberZombie.java    From Cyberware with MIT License 6 votes vote down vote up
@Override
public void onLivingUpdate()
{
	if (!this.hasWare && !this.worldObj.isRemote)
	{
		if (!isBrute() && this.worldObj.rand.nextFloat() < (LibConstants.NATURAL_BRUTE_CHANCE / 100F))
		{
			this.setBrute();
		}
		CyberwareDataHandler.addRandomCyberware(this, isBrute());
		if (isBrute())
		{
			this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(new AttributeModifier("Brute Bonus", 6D, 0));
			this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).applyModifier(new AttributeModifier("Brute Bonus", 1D, 0));
		}
		this.setHealth(this.getMaxHealth());
		hasWare = true;
	}
	if (isBrute() && this.height != (1.95F * 1.2F))
	{
		this.setSizeNormal(0.6F * 1.2F, 1.95F * 1.2F);
	}
	super.onLivingUpdate();
}
 
Example #10
Source File: ItemEnderTool.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack)
{
    Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot, stack);
    //System.out.println("getAttributeModifiers()");
    double dmg = 0.5f; // Default to almost no damage if the tool is broken

    ToolType toolType = ToolType.fromStack(stack);
    // Broken not tool
    if (this.isToolBroken(stack) == false)
    {
        dmg = toolType.getAttackDamage();
    }

    if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
    {
        String modifierName = toolType == ToolType.HOE ? "Weapon modifier" : "Tool modifier";

        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
                new AttributeModifier(ATTACK_DAMAGE_MODIFIER, modifierName, dmg, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
                new AttributeModifier(ATTACK_SPEED_MODIFIER, modifierName, toolType.getAttackSpeed(), 0));
    }

    return multimap;
}
 
Example #11
Source File: ItemEnderSword.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot equipmentSlot, ItemStack stack)
{
    Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot, stack);

    if (equipmentSlot == EntityEquipmentSlot.MAINHAND)
    {
        double dmg = this.damageVsEntity;

        // Broken sword, or in Summon fighters mode, only deal minimal damage directly
        if (this.isToolBroken(stack) || SwordMode.fromStack(stack) == SwordMode.SUMMON)
        {
            dmg = 0.0d;
        }

        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(),
                new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", dmg, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(),
                new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.3D, 0));
    }

    return multimap;
}
 
Example #12
Source File: EssentialsMissingHandler.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void overlayPre(ClientTickEvent event)
{
	if (event.phase == Phase.START && Minecraft.getMinecraft() != null && Minecraft.getMinecraft().thePlayer != null)
	{
		EntityPlayer e = Minecraft.getMinecraft().thePlayer;

		HashMultimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
		multimap.put(SharedMonsterAttributes.MOVEMENT_SPEED.getAttributeUnlocalizedName(), new AttributeModifier(speedId, "Missing leg speed", -100F, 0));
		e.getAttributeMap().removeAttributeModifiers(multimap);
	}
}
 
Example #13
Source File: ItemHandUpgrade.java    From Cyberware with MIT License 5 votes vote down vote up
public void removeUnarmedDamage(EntityLivingBase entity, ItemStack stack)
{
	if (stack.getItemDamage() == 1)
	{
		HashMultimap<String, AttributeModifier> multimap = HashMultimap.<String, AttributeModifier>create();
		
		multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getAttributeUnlocalizedName(), new AttributeModifier(strengthId, "Claws Claws upgrade", 5.5F, 0));
		entity.getAttributeMap().removeAttributeModifiers(multimap);
	}
}
 
Example #14
Source File: WeaponHelper.java    From Levels with GNU General Public License v2.0 5 votes vote down vote up
private static NBTTagCompound writeAttributeModifierToNBT(IAttribute attribute, AttributeModifier modifier, EntityEquipmentSlot slot) 
{
	NBTTagCompound nbt = new NBTTagCompound();
	
	nbt.setString("AttributeName", attribute.getName());
	nbt.setString("Name", modifier.getName());
	nbt.setString("Slot", slot.getName());
	nbt.setDouble("Amount", modifier.getAmount());
	nbt.setInteger("Operation", modifier.getOperation());
	nbt.setLong("UUIDMost", modifier.getID().getMostSignificantBits());
	nbt.setLong("UUIDLeast", modifier.getID().getLeastSignificantBits());
	
	return nbt;
}
 
Example #15
Source File: ItemTerraTool.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack)
{
	Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(slot);

	if (slot == EntityEquipmentSlot.MAINHAND)
	{
		multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier 2", (double)this.damageVsEntity, 0));
		multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", (double)this.attackSpeed, 0));
	}

	return multimap;
}
 
Example #16
Source File: ItemChisel.java    From Chisel-2 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public Multimap getAttributeModifiers(ItemStack stack) {
	Multimap<String, AttributeModifier> multimap = HashMultimap.create();
	multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Chisel Damage", type.attackDamage, 0));
	return multimap;
}
 
Example #17
Source File: EntityUtil.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
public static IAttributeInstance removeModifier(EntityLivingBase ent, IAttribute p, UUID u) {
  IAttributeInstance att = ent.getEntityAttribute(p);
  AttributeModifier curmod = att.getModifier(u);
  if (curmod != null) {
    att.removeModifier(curmod);
  }
  return att;
}
 
Example #18
Source File: EntityWitherCat.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
protected void updateAttackDamage(float growthRatio) {
  IAttributeInstance att = EntityUtil.removeModifier(this, SharedMonsterAttributes.ATTACK_DAMAGE, ATTACK_BOOST_MOD_UID);
  if (growthRatio == 0) {
    return;
  }
  double damageInc = EntityUtil.isHardDifficulty(world) ? Config.witherCatAngryAttackDamageHardModifier : 0;
  double attackDif = (damageInc + Config.witherCatAngryAttackDamage) - Config.witherCatAttackDamage;
  double toAdd = attackDif * growthRatio;
  AttributeModifier mod = new AttributeModifier(ATTACK_BOOST_MOD_UID, "Transformed Attack Modifier", toAdd, 0);
  att.applyModifier(mod);
}
 
Example #19
Source File: EntityWitherCat.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
protected void updateHealth(float growthRatio) {
  IAttributeInstance att = EntityUtil.removeModifier(this, SharedMonsterAttributes.MAX_HEALTH, HEALTH_BOOST_MOD_UID);
  if (growthRatio == 0) {
    return;
  }
  double currentRatio = getHealth() / getMaxHealth();
  double healthDif = Config.witherCatAngryHealth - Config.witherCatHealth;
  double toAdd = healthDif * growthRatio;
  AttributeModifier mod = new AttributeModifier(HEALTH_BOOST_MOD_UID, "Transformed Attack Modifier", toAdd, 0);
  att.applyModifier(mod);

  double newHealth = currentRatio * getMaxHealth();
  setHealth((float) newHealth);

}
 
Example #20
Source File: ItemArtifact.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public Multimap getAttributeModifiers(ItemStack itemStack)
{
	Multimap multimap = super.getAttributeModifiers(itemStack);
    multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)this.weaponDamage, 0));
    return multimap;
}
 
Example #21
Source File: ArtifactTickHandler.java    From Artifacts with MIT License 5 votes vote down vote up
private void updateHealthBoost(int artifactHealthBoostCount, EntityPlayer player) {
	NBTTagCompound playerData = player.getEntityData();
	int oldHealthBoostCount = playerData.getInteger("artifactHealthBoostCount");
	
	if(oldHealthBoostCount != artifactHealthBoostCount) {
		String uu = playerData.getString("artifactHealthBoostUUID");
		UUID healthID;
		
		if(uu.equals("")) {
			healthID = UUID.randomUUID();
			playerData.setString("artifactHealthBoostUUID", healthID.toString());
		}
		else {
			healthID = UUID.fromString(uu);
		}
		
		IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.maxHealth);
		
		atinst.removeModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * oldHealthBoostCount, 0));
		atinst.applyModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * artifactHealthBoostCount, 0));
		
		if(player.getHealth() > player.getMaxHealth()) {
			player.setHealth(player.getMaxHealth());
		}
		int diff = (artifactHealthBoostCount - oldHealthBoostCount);
		if(diff > 0 && player.getHealth() < player.getMaxHealth()) {
			player.heal(5*diff);
		}
		
		playerData.setInteger("artifactHealthBoostCount", artifactHealthBoostCount);
	}
}
 
Example #22
Source File: AutoTool.java    From ForgeHax with MIT License 5 votes vote down vote up
private double getAttackDamage(InvItem item) {
  return Optional.ofNullable(
      item.getItemStack()
          .getAttributeModifiers(EntityEquipmentSlot.MAINHAND)
          .get(SharedMonsterAttributes.ATTACK_DAMAGE.getName()))
      .map(at -> at.stream().findAny().map(AttributeModifier::getAmount).orElse(0.D))
      .orElse(0.D);
}
 
Example #23
Source File: ItemKotachi.java    From Sakura_mod with MIT License 5 votes vote down vote up
/**
 * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
 */
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", this.attackDamage, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -1.6000000953674316D, 0));
    }
    return multimap;
}
 
Example #24
Source File: ItemKatana.java    From Sakura_mod with MIT License 5 votes vote down vote up
/**
 * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
 */
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", this.attackDamage, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.2000000953674316D, 0));
    }
    return multimap;
}
 
Example #25
Source File: ArmorMetaItem.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);
    IArmorLogic armorLogic = getArmorLogic(stack);
    multimap.putAll(armorLogic.getAttributeModifiers(slot, stack));
    return multimap;
}
 
Example #26
Source File: MetaItem.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    HashMultimap<String, AttributeModifier> modifiers = HashMultimap.create();
    T metaValueItem = getItem(stack);
    if (metaValueItem != null) {
        for(IItemBehaviour behaviour : getBehaviours(stack)) {
            modifiers.putAll(behaviour.getAttributeModifiers(slot, stack));
        }
    }
    return modifiers;
}
 
Example #27
Source File: NanoSaberBehavior.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
    HashMultimap<String, AttributeModifier> modifiers = HashMultimap.create();
    if(slot == EntityEquipmentSlot.MAINHAND) {
        float attackDamage = baseAttackDamage + (isItemActive(stack) ? additionalAttackDamage : 0.0f);
        modifiers.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.0, 0));
        modifiers.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon Modifier", attackDamage, 0));
    }
    return modifiers;
}
 
Example #28
Source File: GTItemTeslaStaff.java    From GT-Classic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmentSlot slot, ItemStack stack) {
	Multimap<String, AttributeModifier> map = HashMultimap.create();
	if (slot == EntityEquipmentSlot.MAINHAND) {
		if (ElectricItem.manager.canUse(stack, this.operationEnergyCost)) {
			map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", 512.0D, 0));
		} else {
			map.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Tool modifier", 1.0D, 0));
		}
	}
	return map;
}
 
Example #29
Source File: ItemShinai.java    From Sakura_mod with MIT License 5 votes vote down vote up
/**
 * Gets a map of item attribute modifiers, used by ItemSword to increase hit damage.
 */
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", this.attackDamage, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -2.2000000953674316D, 0));
    }
    return multimap;
}
 
Example #30
Source File: AutoTool.java    From ForgeHax with MIT License 5 votes vote down vote up
private double getAttackSpeed(InvItem item) {
  return Optional.ofNullable(
      item.getItemStack()
          .getAttributeModifiers(EntityEquipmentSlot.MAINHAND)
          .get(SharedMonsterAttributes.ATTACK_DAMAGE.getName()))
      .map(
          at ->
              at.stream().findAny().map(AttributeModifier::getAmount).map(Math::abs).orElse(0.D))
      .orElse(0.D);
}