Java Code Examples for net.minecraft.inventory.EntityEquipmentSlot#MAINHAND

The following examples show how to use net.minecraft.inventory.EntityEquipmentSlot#MAINHAND . 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: 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 2
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 3
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 4
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 5
Source File: CraftEntityEquipment.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private float getDropChance(EntityEquipmentSlot slot) {
    if (slot == EntityEquipmentSlot.MAINHAND || slot == EntityEquipmentSlot.OFFHAND) {
        return ((EntityLiving) entity.getHandle()).inventoryHandsDropChances[slot.getIndex()] + 0.1F;
    } else {
        return ((EntityLiving) entity.getHandle()).inventoryArmorDropChances[slot.getIndex()] + 0.1F;
    }
}
 
Example 6
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 7
Source File: ItemUnicornDagger.java    From Wizardry 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> modifiers = super.getAttributeModifiers(slot, stack);

	if (slot == EntityEquipmentSlot.MAINHAND) {
		modifiers.removeAll(SharedMonsterAttributes.ATTACK_DAMAGE.getName());
		modifiers.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", EnchantmentHelper.getEnchantmentLevel(Enchantments.KNOCKBACK, stack), 0));
	}

	return modifiers;
}
 
Example 8
Source File: ItemSword.java    From customstuff4 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 = HashMultimap.create();

    if (slot == EntityEquipmentSlot.MAINHAND)
    {
        double damage = attackDamage != null ? attackDamage : defaultAttackDamage;
        double speed = attackSpeed != null ? attackSpeed : defaultAttackSpeed;
        multimap.put(SharedMonsterAttributes.ATTACK_DAMAGE.getName(), new AttributeModifier(ATTACK_DAMAGE_MODIFIER, "Weapon modifier", damage, 0));
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", speed, 0));
    }
    return multimap;
}
 
Example 9
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 10
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 11
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 12
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 13
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 14
Source File: EnchantmentWitherWeapon.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public EnchantmentWitherWeapon() {
  super(Config.enchantmentWitherWeaponRarity, EnumEnchantmentType.WEAPON, new EntityEquipmentSlot[] {EntityEquipmentSlot.MAINHAND, EntityEquipmentSlot.OFFHAND});    
  setName(NAME);
  setRegistryName(NAME);

}
 
Example 15
Source File: EnchantmentDrain.java    From TofuCraftReload with MIT License 4 votes vote down vote up
protected EnchantmentDrain() {
	super(Enchantment.Rarity.COMMON, EnchantmentLoader.typeDiamondTofu, new EntityEquipmentSlot[]{
			EntityEquipmentSlot.MAINHAND,EntityEquipmentSlot.OFFHAND
	});
}
 
Example 16
Source File: EnchantmentEnderDamage.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
private EnchantmentEnderDamage() {
    super(Rarity.UNCOMMON, EnumEnchantmentType.WEAPON, new EntityEquipmentSlot[]{EntityEquipmentSlot.MAINHAND});
}
 
Example 17
Source File: EnchantmentEfficiency.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
protected EnchantmentEfficiency()
{
    super(Rarity.COMMON, EnumEnchantmentType.DIGGER, new EntityEquipmentSlot[] { EntityEquipmentSlot.MAINHAND });
    this.setName("sieveEfficiency");
    this.setRegistryName("sieveEfficiency");
}
 
Example 18
Source File: EnchantmentLuckOfTheSea.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
protected EnchantmentLuckOfTheSea()
{
    super(Rarity.RARE, EnumEnchantmentType.DIGGER, new EntityEquipmentSlot[] { EntityEquipmentSlot.MAINHAND });
    this.setName("sieveLuckOfTheSea");
    this.setRegistryName("sieveLuckOfTheSea");
}
 
Example 19
Source File: EnchantmentFortune.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
protected EnchantmentFortune()
{
    super(Rarity.RARE, EnumEnchantmentType.DIGGER, new EntityEquipmentSlot[] { EntityEquipmentSlot.MAINHAND });
    this.setName("sieveFortune");
    this.setRegistryName("sieveFortune");
}
 
Example 20
Source File: EnchantmentBatch.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public EnchantmentBatch(){
super(Enchantment.Rarity.COMMON, EnchantmentLoader.typeDiamondTofu, new EntityEquipmentSlot[]{
		EntityEquipmentSlot.MAINHAND,EntityEquipmentSlot.OFFHAND
});
  }