实现了装备的动态属性
This commit is contained in:
parent
14bae3e12e
commit
69c4efd6b2
2 changed files with 14 additions and 12 deletions
|
@ -25,6 +25,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
public class RuChest6b43 extends ArmorItem implements GeoItem {
|
public class RuChest6b43 extends ArmorItem implements GeoItem {
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public RuChest6b43() {
|
public RuChest6b43() {
|
||||||
super(ModArmorMaterial.CEMENTED_CARBIDE, Type.CHESTPLATE, new Properties());
|
super(ModArmorMaterial.CEMENTED_CARBIDE, Type.CHESTPLATE, new Properties());
|
||||||
}
|
}
|
||||||
|
@ -45,13 +46,13 @@ public class RuChest6b43 extends ArmorItem implements GeoItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentSlot) {
|
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlot slot, ItemStack stack) {
|
||||||
Multimap<Attribute, AttributeModifier> map = super.getDefaultAttributeModifiers(equipmentSlot);
|
Multimap<Attribute, AttributeModifier> map = super.getDefaultAttributeModifiers(slot);
|
||||||
UUID uuid = new UUID(equipmentSlot.toString().hashCode(), 0);
|
UUID uuid = new UUID(slot.toString().hashCode(), 0);
|
||||||
if (equipmentSlot == EquipmentSlot.CHEST) {
|
if (slot == EquipmentSlot.CHEST) {
|
||||||
map = HashMultimap.create(map);
|
map = HashMultimap.create(map);
|
||||||
map.put(ModAttributes.BULLET_RESISTANCE.get(), new AttributeModifier(uuid, ModUtils.ATTRIBUTE_MODIFIER, 0.5f, AttributeModifier.Operation.ADDITION));
|
map.put(ModAttributes.BULLET_RESISTANCE.get(), new AttributeModifier(uuid, ModUtils.ATTRIBUTE_MODIFIER,
|
||||||
|
0.5 * Math.max(0, 1 - (double) stack.getDamageValue() / stack.getMaxDamage()), AttributeModifier.Operation.ADDITION));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
public class RuHelmet6b47 extends ArmorItem implements GeoItem {
|
public class RuHelmet6b47 extends ArmorItem implements GeoItem {
|
||||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||||
|
|
||||||
public RuHelmet6b47() {
|
public RuHelmet6b47() {
|
||||||
super(ModArmorMaterial.CEMENTED_CARBIDE, Type.HELMET, new Properties());
|
super(ModArmorMaterial.CEMENTED_CARBIDE, Type.HELMET, new Properties());
|
||||||
}
|
}
|
||||||
|
@ -45,13 +46,13 @@ public class RuHelmet6b47 extends ArmorItem implements GeoItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot equipmentSlot) {
|
public Multimap<Attribute, AttributeModifier> getAttributeModifiers(EquipmentSlot slot, ItemStack stack) {
|
||||||
Multimap<Attribute, AttributeModifier> map = super.getDefaultAttributeModifiers(equipmentSlot);
|
Multimap<Attribute, AttributeModifier> map = super.getDefaultAttributeModifiers(slot);
|
||||||
UUID uuid = new UUID(equipmentSlot.toString().hashCode(), 0);
|
UUID uuid = new UUID(slot.toString().hashCode(), 0);
|
||||||
if (equipmentSlot == EquipmentSlot.HEAD) {
|
if (slot == EquipmentSlot.HEAD) {
|
||||||
map = HashMultimap.create(map);
|
map = HashMultimap.create(map);
|
||||||
map.put(ModAttributes.BULLET_RESISTANCE.get(), new AttributeModifier(uuid, ModUtils.ATTRIBUTE_MODIFIER, 0.2f, AttributeModifier.Operation.ADDITION));
|
map.put(ModAttributes.BULLET_RESISTANCE.get(), new AttributeModifier(uuid, ModUtils.ATTRIBUTE_MODIFIER,
|
||||||
|
0.2 * Math.max(0, 1 - (double) stack.getDamageValue() / stack.getMaxDamage()), AttributeModifier.Operation.ADDITION));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue