use of net.minecraft.entity.ai.attributes.AttributeModifier in project Gaia-Dimension by Andromander.
the class GDApexPredatorSword method getItemAttributeModifiers.
// TODO: Deal Bleeding damage/effect
// TODO: [FUTURE] Can be used to unlock Unknown Spinel Princess Structure
// We will need this in order to make the weapon slow
@Override
@Nonnull
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
// This is not our speed anymore
multimap.removeAll(SharedMonsterAttributes.ATTACK_SPEED.getName());
// Speed is set to 0.8; 0.8 less than normal
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -3.2, 0));
}
return multimap;
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project Gaia-Dimension by Andromander.
the class GDGaiaDukeSword method getItemAttributeModifiers.
// TODO: Deals extra damage to Gaian mobs
// TODO: [FUTURE] Can be used to unlock Unknown Stage 4 Final Boss Structure
// We will need this in order to make the weapon slow
@Override
@Nonnull
public Multimap<String, AttributeModifier> getItemAttributeModifiers(EntityEquipmentSlot equipmentSlot) {
Multimap<String, AttributeModifier> multimap = super.getItemAttributeModifiers(equipmentSlot);
if (equipmentSlot == EntityEquipmentSlot.MAINHAND) {
// This is not our speed anymore
multimap.removeAll(SharedMonsterAttributes.ATTACK_SPEED.getName());
// Speed is set to 1; 0.6 less than normal
multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Weapon modifier", -3, 0));
}
return multimap;
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemKeyblade method replaceModifier.
private void replaceModifier(Multimap<String, AttributeModifier> modifierMultimap, IAttribute attribute, UUID id, double multiplier) {
// Get the modifiers for the specified attribute
final Collection<AttributeModifier> modifiers = modifierMultimap.get(attribute.getName());
// Find the modifier with the specified ID, if any
final Optional<AttributeModifier> modifierOptional = modifiers.stream().filter(attributeModifier -> attributeModifier.getID().equals(id)).findFirst();
if (modifierOptional.isPresent()) {
// If it exists,
final AttributeModifier modifier = modifierOptional.get();
// Remove it
modifiers.remove(modifier);
// Add the new modifier
modifiers.add(new AttributeModifier(modifier.getID(), modifier.getName(), modifier.getAmount() * multiplier, modifier.getOperation()));
}
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project Kingdom-Keys-Re-Coded by Wehavecookies56.
the class ItemEvents method addTooltip.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void addTooltip(ItemTooltipEvent event) {
List<String> tooltip = event.getToolTip();
for (ItemStack stack : MunnyRegistry.munnyValues.keySet()) {
if (areItemStacksEqual(stack, event.getItemStack())) {
event.getToolTip().add(TextFormatting.YELLOW + "Munny: " + MunnyRegistry.munnyValues.get(stack) * event.getItemStack().getCount());
}
}
// TODO Localize all this
if (event.getItemStack().getItem() instanceof ItemKeyblade && event.getEntityPlayer() != null) {
// List<String> tooltip = event.getToolTip();
ItemKeyblade keyblade = (ItemKeyblade) event.getItemStack().getItem();
(tooltip.subList(1, tooltip.size())).clear();
NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
double sharpnessDamage = 0;
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
// System.out.println(Enchantment.getEnchantmentByID(id).getName());
if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
sharpnessDamage = getSharpnessDamage(lvl);
}
}
double keyStrength = keyblade.getStrength() + sharpnessDamage;
String magicSymbol = (keyblade.getMagic() > 0) ? "+" : "-";
tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength * MainConfig.items.damageMultiplier + " [" + (DamageCalculation.getStrengthDamage(event.getEntityPlayer(), keyblade) + sharpnessDamage) + "]");
tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + keyblade.getMagic() * MainConfig.items.damageMultiplier + " [" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, keyblade) + "]");
if (keyblade.getDescription() != null) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
tooltip.add(keyblade.description);
tooltip.add("");
} else {
tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
if (event.getItemStack().hasTagCompound()) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id) != null) {
tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
}
}
}
for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) {
Multimap<String, AttributeModifier> multimap = event.getItemStack().getAttributeModifiers(entityequipmentslot);
if (!multimap.isEmpty()) {
tooltip.add("");
for (Map.Entry<String, AttributeModifier> entry : multimap.entries()) {
AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
double d0 = attributemodifier.getAmount();
boolean flag = false;
if (attributemodifier.getID() == UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")) {
d0 = d0 + event.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
d0 = d0 + (double) EnchantmentHelper.getModifierForCreature(event.getItemStack(), EnumCreatureAttribute.UNDEFINED);
flag = true;
}
double d1;
if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) {
d1 = d0;
} else {
d1 = d0 * 100.0D;
}
if (entry.getKey() == "generic.attackDamage") {
d1 += event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null).getStrength();
}
if (flag) {
tooltip.add(Utils.translateToLocalFormatted("attribute.modifier.equals." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 > 0.0D) {
tooltip.add(TextFormatting.BLUE + Utils.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 < 0.0D) {
d1 = d1 * -1.0D;
tooltip.add(TextFormatting.RED + Utils.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
}
}
}
}
} else {
tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
}
}
if (event.getItemStack().getItem() instanceof ItemKeychain && event.getEntityPlayer() != null) {
// List<String> tooltip = event.getToolTip();
ItemKeyblade keyblade = ((ItemKeychain) event.getItemStack().getItem()).getKeyblade();
if (keyblade != null) {
(tooltip.subList(1, tooltip.size())).clear();
NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
double sharpnessDamage = 0;
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
sharpnessDamage = getSharpnessDamage(lvl);
}
}
double keyStrength = keyblade.getStrength() + sharpnessDamage;
String magicSymbol = (keyblade.getMagic() > 0) ? "+" : "";
tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength * MainConfig.items.damageMultiplier + " [" + (DamageCalculation.getStrengthDamage(event.getEntityPlayer(), keyblade) + sharpnessDamage) + "]");
tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + keyblade.getMagic() * MainConfig.items.damageMultiplier + " [" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, keyblade) + "]");
if (keyblade.getDescription() != null) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
tooltip.add(keyblade.description);
tooltip.add("");
} else {
tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
if (event.getItemStack().hasTagCompound()) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id) != null) {
tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
}
}
}
} else {
tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
}
}
}
if (event.getItemStack().getItem() instanceof IOrgWeapon) {
IOrgWeapon weapon = (IOrgWeapon) event.getItemStack().getItem();
(tooltip.subList(1, tooltip.size())).clear();
NBTTagList nbttaglist = event.getItemStack().getEnchantmentTagList();
double sharpnessDamage = 0;
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
// System.out.println(Enchantment.getEnchantmentByID(id).getName());
if (Enchantment.getEnchantmentByID(id).getName().equals("enchantment.damage.all")) {
sharpnessDamage = getSharpnessDamage(lvl);
}
}
double keyStrength = weapon.getStrength() + sharpnessDamage;
String magicSymbol = (weapon.getMagic() > 0) ? "+" : "";
tooltip.add(TextFormatting.RED + "Strength: +" + keyStrength + " (" + (DamageCalculation.getOrgStrengthDamage(event.getEntityPlayer(), event.getItemStack()) + sharpnessDamage) + ")");
tooltip.add(TextFormatting.BLUE + "Magic: " + magicSymbol + weapon.getMagic() + " (" + DamageCalculation.getMagicDamage(event.getEntityPlayer(), 1, weapon) + ")");
if (weapon.getDescription() != null) {
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Description");
tooltip.add(weapon.getDescription());
tooltip.add("");
} else {
tooltip.add("Hold " + TextFormatting.GREEN + TextFormatting.ITALIC + "Shift" + TextFormatting.GRAY + " for description");
}
}
if (Keyboard.isKeyDown(Keyboard.KEY_LMENU)) {
if (event.getItemStack().hasTagCompound()) {
tooltip.add("" + TextFormatting.WHITE + TextFormatting.UNDERLINE + "Stats");
for (int i = 0; i < nbttaglist.tagCount(); i++) {
int id = nbttaglist.getCompoundTagAt(i).getShort("id");
int lvl = nbttaglist.getCompoundTagAt(i).getShort("lvl");
if (Enchantment.getEnchantmentByID(id) != null) {
tooltip.add(Enchantment.getEnchantmentByID(id).getTranslatedName(lvl));
}
}
}
for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values()) {
Multimap<String, AttributeModifier> multimap = event.getItemStack().getAttributeModifiers(entityequipmentslot);
if (!multimap.isEmpty()) {
tooltip.add("");
for (Map.Entry<String, AttributeModifier> entry : multimap.entries()) {
AttributeModifier attributemodifier = (AttributeModifier) entry.getValue();
double d0 = attributemodifier.getAmount();
boolean flag = false;
if (attributemodifier.getID() == UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF")) {
d0 = d0 + event.getEntityPlayer().getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getBaseValue();
d0 = d0 + (double) EnchantmentHelper.getModifierForCreature(event.getItemStack(), EnumCreatureAttribute.UNDEFINED);
flag = true;
}
double d1;
if (attributemodifier.getOperation() != 1 && attributemodifier.getOperation() != 2) {
d1 = d0;
} else {
d1 = d0 * 100.0D;
}
if (entry.getKey() == "generic.attackDamage") {
d1 += event.getEntityPlayer().getCapability(ModCapabilities.PLAYER_STATS, null).getStrength();
}
if (flag) {
tooltip.add(Utils.translateToLocalFormatted("attribute.modifier.equals." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 > 0.0D) {
tooltip.add(TextFormatting.BLUE + Utils.translateToLocalFormatted("attribute.modifier.plus." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
} else if (d0 < 0.0D) {
d1 = d1 * -1.0D;
tooltip.add(TextFormatting.RED + Utils.translateToLocalFormatted("attribute.modifier.take." + attributemodifier.getOperation(), new Object[] { ItemStack.DECIMALFORMAT.format(d1), Utils.translateToLocal("attribute.name." + (String) entry.getKey()) }));
}
}
}
}
} else {
tooltip.add("Hold " + TextFormatting.YELLOW + TextFormatting.ITALIC + "Alt" + TextFormatting.GRAY + " for more stats");
}
}
if (event.getItemStack().getItem() instanceof IOrgWeapon && event.getItemStack().getItem() != ModItems.DreamShield) {
String member = ((IOrgWeapon) event.getItemStack().getItem()).getMember().toString();
tooltip.add(member.substring(0, 1) + member.substring(1, member.length()).toLowerCase());
}
Item ghostBlox = Item.getItemFromBlock(ModBlocks.GhostBlox);
if (event.getItemStack().getItem() == ghostBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
int x = 30;
String s = Utils.translateToLocal(Strings.GhostBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.GhostBlox.getUnlocalizedName() + ".name"));
s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
String[] splitS = s.split("\n");
for (String element : splitS) event.getToolTip().add(element);
}
}
Item dangerBlox = Item.getItemFromBlock(ModBlocks.DangerBlox);
if (event.getItemStack().getItem() == dangerBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
int x = 30;
String s = Utils.translateToLocal(Strings.DangerBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.DangerBlox.getUnlocalizedName() + ".name"));
s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
String[] splitS = s.split("\n");
for (String element : splitS) event.getToolTip().add(element);
}
}
Item bounceBlox = Item.getItemFromBlock(ModBlocks.BounceBlox);
if (event.getItemStack().getItem() == bounceBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
int x = 30;
String s = Utils.translateToLocal(Strings.BounceBloxDesc).replace("%s", Utils.translateToLocal(ModBlocks.BounceBlox.getUnlocalizedName() + ".name"));
s = s.replaceAll("(.{" + x + ",}?)\\s+", "$1\n");
String[] splitS = s.split("\n");
for (String element : splitS) event.getToolTip().add(element);
}
}
Item magnetBlox = Item.getItemFromBlock(ModBlocks.MagnetBlox);
if (event.getItemStack().getItem() == magnetBlox) {
if (!KeyboardHelper.isShiftDown()) {
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
} else {
event.getToolTip().add("This Block is WIP and doesn't work at all.");
event.getToolTip().add("It won't crash your game though.");
}
}
Item kkchest = Item.getItemFromBlock(ModBlocks.KKChest);
if (event.getItemStack().getItem() == kkchest) {
// event.getToolTip().add(Utils.translateToLocal(Strings.KKChestDesc_1));
if (!KeyboardHelper.isShiftDown())
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
else
event.getToolTip().add(Utils.translateToLocal(Strings.KKChestDesc_2));
}
Item savepoint = Item.getItemFromBlock(ModBlocks.SavePoint);
if (event.getItemStack().getItem() == savepoint)
if (!KeyboardHelper.isShiftDown())
event.getToolTip().add(TextFormatting.ITALIC + Utils.translateToLocal(Strings.HoldForInfo));
else
event.getToolTip().add(Utils.translateToLocal(Strings.SavePointDesc));
}
use of net.minecraft.entity.ai.attributes.AttributeModifier in project Minestuck by mraof.
the class Echeladder method updateEcheladderBonuses.
public void updateEcheladderBonuses(EntityPlayer player) {
int healthBonus = healthBoost(rung);
double damageBonus = attackBonus(rung);
// If this isn't saved, your health goes to 10 hearts (if it was higher before) when loading the save file.
updateAttribute(player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH), new AttributeModifier(echeladderHealthBoostModifierUUID, "Echeladder Health Boost", healthBonus, 0));
updateAttribute(player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE), new AttributeModifier(echeladderDamageBoostModifierUUID, "Echeladder Damage Boost", damageBonus, 1).setSaved(false));
}
Aggregations