Bon problème résolut pour tout ceux qui cherche comment on fait petit cadeau c’était pas de tout repos de comprendre comment fonctionnait tout ca 😜
import java.util.UUID;
import com.raiden.virusz.items.tools.ToolSword;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.IAttribute;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
public class Upgrades
{
public final static UUID MODIFIER_UUID = UUID.randomUUID();
public static ItemStack upgrade(ToolSword item,EntityEquipmentSlot slot ,double upgradeDamage, double upgradeSpeed) {
double Damage = 4 + item.getAttackDamage();
double Speed = item.getAttackSpeed();
AttributeModifier attackModifier = new AttributeModifier(MODIFIER_UUID, "Weapon Upgrade", upgradeDamage + Damage, 0);
AttributeModifier speedModifier = new AttributeModifier(MODIFIER_UUID, "Weapon Upgrade", upgradeSpeed + Speed, 0);
NBTTagCompound modifierATQ = writeAttributeModifierToNBT(SharedMonsterAttributes.ATTACK_DAMAGE, attackModifier, EntityEquipmentSlot.MAINHAND);
NBTTagCompound modifierSpd = writeAttributeModifierToNBT(SharedMonsterAttributes.ATTACK_SPEED, speedModifier, EntityEquipmentSlot.MAINHAND);
NBTTagCompound stackTagCompound = new NBTTagCompound();
NBTTagList list = new NBTTagList();
list.appendTag(modifierATQ);
list.appendTag(modifierSpd);
stackTagCompound.setTag("AttributeModifiers", list);
ItemStack stack = new ItemStack(item);
stack.setTagCompound(stackTagCompound);
return stack;
}
private static NBTTagCompound writeAttributeModifierToNBT(IAttribute attribute, AttributeModifier modifier, EntityEquipmentSlot slot) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("AttributeName", attribute.getName());
nbttagcompound.setString("Name", modifier.getName());
nbttagcompound.setDouble("Amount", modifier.getAmount());
nbttagcompound.setInteger("Operation", modifier.getOperation());
nbttagcompound.setString("Slot", slot.getName());
nbttagcompound.setLong("UUIDMost", modifier.getID().getMostSignificantBits());
nbttagcompound.setLong("UUIDLeast", modifier.getID().getLeastSignificantBits());
return nbttagcompound;
}
pour l’appel je le fait de cette façon
//usage Upgrades.upgrade(item, slot, +Damage, +SpeedReduction);
ItemStack sword = Upgrades.upgrade(ItemInit.SWORD, EntityEquipmentSlot.MAINHAND, 12.0D, 0.0D);
GameRegistry.addSmelting(new ItemStack(ItemInit.SWORD_RUBY), sword, 0.4F);