Каждый тик проверяй, что находится в слотах брони игрока, если это определённая броня, то изменяй макс. количество хп(setMaxHealth).Как изменить к примеру макс. кол-во ХП, когда броня одета, а когда снята, сделать как было раньше?
Пример: Я одел свои поножи, у меня здоровье выросло на 10%
Руки бы тебе оторвать. Атрибуты для кого?то изменяй макс. количество хп(setMaxHealth)
player.getEntityAttribute (SharedMonsterAttributes.movementSpeed) .setBaseValue (player.getEntityAttribute (SharedMonsterAttributes.movementSpeed).getBaseValue*1.1);
private static UUID uuid = UUID.fromString("42c8426d-7e85-4a61-a883-72e85c656fab");
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
if(world.isRemote)return;
AbstractAttributeMap map = player.getAttributeMap();
if(map.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED).getModifier(uuid) != null){
map.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(uuid);
}
if(player.inventory.armorItemInSlot(0).getItem() == ItemsMod.DARK_BOOTS) {
if (player.inventory.armorItemInSlot(1).getItem() == ItemsMod.DARK_LEGS) {
if (player.inventory.armorItemInSlot(2).getItem() == ItemsMod.DARK_CHEST) {
if (player.inventory.armorItemInSlot(3).getItem() == ItemsMod.DARK_HEAD) {
map.getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED).applyModifier(new AttributeModifier(uuid, "Lol", -10F, 1));
}
}
}
}
}
for (int j = 0; j < 5; ++j)
{
ItemStack itemstack = this.previousEquipment[j];
ItemStack itemstack1 = this.getEquipmentInSlot(j);
if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
{
((WorldServer)this.worldObj).getEntityTracker().func_151247_a(this, new S04PacketEntityEquipment(this.getEntityId(), j, itemstack1));
if (itemstack != null)
{
this.attributeMap.removeAttributeModifiers(itemstack.getAttributeModifiers());
}
if (itemstack1 != null)
{
this.attributeMap.applyAttributeModifiers(itemstack1.getAttributeModifiers());
}
this.previousEquipment[j] = itemstack1 == null ? null : itemstack1.copy();
}
}