Skip to content

Commit

Permalink
Update Attribute variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo56958 committed Dec 4, 2024
1 parent 1ff52cc commit db33587
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 9 additions & 9 deletions src/main/java/de/flo56958/minetinker/modifiers/ModManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -973,37 +973,37 @@ public void addArmorAttributes(@NotNull final ItemStack is) {
knockbackResAM = new AttributeModifier(nkKnockbackRes, knockback_res, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.LEGS);
} else if (!ToolType.ELYTRA.contains(is.getType())) return;

Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.GENERIC_ARMOR);
Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.ARMOR);
if (list != null) {
list = new ArrayList<>(list); // Collection is immutable
list.removeIf(am -> !nkArmor.getNamespace().equals(am.getKey().getNamespace()));
list.removeIf(am -> !nkArmor.getKey().contains(am.getKey().getKey()));
list.forEach(am -> meta.removeAttributeModifier(Attribute.GENERIC_ARMOR, am));
list.forEach(am -> meta.removeAttributeModifier(Attribute.ARMOR, am));
}
if (armor > 0.0d && armorAM != null) {
meta.addAttributeModifier(Attribute.GENERIC_ARMOR, armorAM);
meta.addAttributeModifier(Attribute.ARMOR, armorAM);
}

list = meta.getAttributeModifiers(Attribute.GENERIC_ARMOR_TOUGHNESS);
list = meta.getAttributeModifiers(Attribute.ARMOR_TOUGHNESS);
if (list != null) {
list = new ArrayList<>(list); // Collection is immutable
list.removeIf(am -> !nkArmorToughness.getNamespace().equals(am.getKey().getNamespace()));
list.removeIf(am -> !nkArmorToughness.getKey().contains(am.getKey().getKey()));
list.forEach(am -> meta.removeAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS, am));
list.forEach(am -> meta.removeAttributeModifier(Attribute.ARMOR_TOUGHNESS, am));
}
if (toughness > 0.0d && toughnessAM != null) {
meta.addAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS, toughnessAM);
meta.addAttributeModifier(Attribute.ARMOR_TOUGHNESS, toughnessAM);
}

list = meta.getAttributeModifiers(Attribute.GENERIC_KNOCKBACK_RESISTANCE);
list = meta.getAttributeModifiers(Attribute.KNOCKBACK_RESISTANCE);
if (list != null) {
list = new ArrayList<>(list); // Collection is immutable
list.removeIf(am -> !nkKnockbackRes.getNamespace().equals(am.getKey().getNamespace()));
list.removeIf(am -> !nkKnockbackRes.getKey().contains(am.getKey().getKey()));
list.forEach(am -> meta.removeAttributeModifier(Attribute.GENERIC_KNOCKBACK_RESISTANCE, am));
list.forEach(am -> meta.removeAttributeModifier(Attribute.KNOCKBACK_RESISTANCE, am));
}
if (knockback_res > 0.0d && knockbackResAM != null) {
meta.addAttributeModifier(Attribute.GENERIC_KNOCKBACK_RESISTANCE, knockbackResAM);
meta.addAttributeModifier(Attribute.KNOCKBACK_RESISTANCE, knockbackResAM);
}

if (config.getBoolean("HideAttributes")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void onHit(@NotNull EntityDamageEvent event) {
if (modifierLevel <= 0) return;

final double lifeAfterDamage = player.getHealth() - event.getFinalDamage();
AttributeInstance healthAttr = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
AttributeInstance healthAttr = player.getAttribute(Attribute.MAX_HEALTH);

double maxHealth = 20;
if (healthAttr != null) maxHealth = healthAttr.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public List<ToolType> getAllowedTools() {

@Override
public @NotNull List<Attribute> getAppliedAttributes() {
return Arrays.asList(Attribute.GENERIC_ARMOR, Attribute.GENERIC_ARMOR_TOUGHNESS);
return Arrays.asList(Attribute.ARMOR, Attribute.ARMOR_TOUGHNESS);
}

@Override
Expand Down Expand Up @@ -81,7 +81,7 @@ public boolean applyMod(Player player, ItemStack tool, boolean isCommand) {
default -> null;
};
assert armorAM != null;
meta.addAttributeModifier(Attribute.GENERIC_ARMOR, armorAM);
meta.addAttributeModifier(Attribute.ARMOR, armorAM);
}
}

Expand All @@ -102,7 +102,7 @@ public boolean applyMod(Player player, ItemStack tool, boolean isCommand) {
default -> null;
};
assert toughnessAM != null;
meta.addAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS, toughnessAM);
meta.addAttributeModifier(Attribute.ARMOR_TOUGHNESS, toughnessAM);
}
}
tool.setItemMeta(meta);
Expand All @@ -120,21 +120,21 @@ public void removeMod(ItemStack tool) {
final ToolType toolType = ToolType.get(tool.getType());

final NamespacedKey nkArmor = new NamespacedKey(MineTinker.getPlugin(), this.sArmor + toolType.name());
Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.GENERIC_ARMOR);
Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.ARMOR);
if (list != null) {
list = new ArrayList<>(list); // Collection is immutable
list.removeIf(am -> !nkArmor.getNamespace().equals(am.getKey().getNamespace()));
list.removeIf(am -> !nkArmor.getKey().contains(am.getKey().getKey()));
list.forEach(am -> meta.removeAttributeModifier(Attribute.GENERIC_ARMOR, am));
list.forEach(am -> meta.removeAttributeModifier(Attribute.ARMOR, am));
}

final NamespacedKey nkArmorToughness = new NamespacedKey(MineTinker.getPlugin(), this.sArmorToughness + toolType.name());
list = meta.getAttributeModifiers(Attribute.GENERIC_ARMOR_TOUGHNESS);
list = meta.getAttributeModifiers(Attribute.ARMOR_TOUGHNESS);
if (list != null) {
list = new ArrayList<>(list); // Collection is immutable
list.removeIf(am -> !nkArmorToughness.getNamespace().equals(am.getKey().getNamespace()));
list.removeIf(am -> !nkArmorToughness.getKey().contains(am.getKey().getKey()));
list.forEach(am -> meta.removeAttributeModifier(Attribute.GENERIC_ARMOR_TOUGHNESS, am));
list.forEach(am -> meta.removeAttributeModifier(Attribute.ARMOR_TOUGHNESS, am));
}
tool.setItemMeta(meta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void effect(MTEntityDamageByEntityEvent event) {
final double recovery = damage * ((percentPerLevel * level) / 100.0);
final double health = player.getHealth() + recovery;

AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
AttributeInstance attribute = player.getAttribute(Attribute.MAX_HEALTH);

if (attribute != null) // for IllegalArgumentException if Health is bigger than MaxHealth
player.setHealth(Math.min(health, attribute.getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void onDamage(final EntityDamageEvent event) {
if (damage > 0) {
event.setDamage(0);
double health = player.getHealth();
player.setHealth(Math.min(health + damage, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
player.setHealth(Math.min(health + damage, player.getAttribute(Attribute.MAX_HEALTH).getValue()));
ChatWriter.logModifier(player, event, this, armor, String.format("Health(%.2f -> %.2f)", health, player.getHealth()));
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/de/flo56958/minetinker/modifiers/types/Speedy.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public List<ToolType> getAllowedTools() {

@Override
public @NotNull List<Attribute> getAppliedAttributes() {
return Collections.singletonList(Attribute.GENERIC_MOVEMENT_SPEED);
return Collections.singletonList(Attribute.MOVEMENT_SPEED);
}

private final String sMovementSpeed = this.getKey() + ".movement_speed_";
Expand All @@ -63,12 +63,12 @@ public void removeMod(ItemStack tool) {
final ToolType toolType = ToolType.get(tool.getType());
final NamespacedKey nkMovementSpeed = new NamespacedKey(MineTinker.getPlugin(), sMovementSpeed + toolType.name());

Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.GENERIC_MOVEMENT_SPEED);
Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.MOVEMENT_SPEED);
if (list != null) {
list = new ArrayList<>(list); // Collection is immutable
list.removeIf(am -> !nkMovementSpeed.getNamespace().equals(am.getKey().getNamespace()));
list.removeIf(am -> !nkMovementSpeed.getKey().contains(am.getKey().getKey()));
list.forEach(am -> meta.removeAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, am));
list.forEach(am -> meta.removeAttributeModifier(Attribute.MOVEMENT_SPEED, am));
}

tool.setItemMeta(meta);
Expand All @@ -86,11 +86,11 @@ public boolean applyMod(Player player, ItemStack tool, boolean isCommand) {
final NamespacedKey nkMovementSpeed = new NamespacedKey(MineTinker.getPlugin(), sMovementSpeed + toolType.name());

if (ToolType.LEGGINGS.contains(tool.getType()))
meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED,
meta.addAttributeModifier(Attribute.MOVEMENT_SPEED,
new AttributeModifier(nkMovementSpeed, level * this.speedPerLevel,
AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.LEGS));
else
meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED,
meta.addAttributeModifier(Attribute.MOVEMENT_SPEED,
new AttributeModifier(nkMovementSpeed, level * this.speedPerLevel,
AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.FEET));

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/de/flo56958/minetinker/modifiers/types/Tanky.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public List<ToolType> getAllowedTools() {

@Override
public @NotNull List<Attribute> getAppliedAttributes() {
return Collections.singletonList(Attribute.GENERIC_MAX_HEALTH);
return Collections.singletonList(Attribute.MAX_HEALTH);
}

private final String sHealth = this.getKey() + ".max_health_";
Expand All @@ -74,12 +74,12 @@ public void removeMod(ItemStack tool) {
final ToolType toolType = ToolType.get(tool.getType());
final NamespacedKey nkHealth = new NamespacedKey(MineTinker.getPlugin(), sHealth + toolType.name());

Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.GENERIC_MAX_HEALTH);
Collection<AttributeModifier> list = meta.getAttributeModifiers(Attribute.MAX_HEALTH);
if (list != null) {
list = new ArrayList<>(list); // Collection is immutable
list.removeIf(am -> !nkHealth.getNamespace().equals(am.getKey().getNamespace()));
list.removeIf(am -> !nkHealth.getKey().contains(am.getKey().getKey()));
list.forEach(am -> meta.removeAttributeModifier(Attribute.GENERIC_MAX_HEALTH, am));
list.forEach(am -> meta.removeAttributeModifier(Attribute.MAX_HEALTH, am));
}

tool.setItemMeta(meta);
Expand All @@ -98,10 +98,10 @@ public boolean applyMod(Player player, ItemStack tool, boolean isCommand) {
final NamespacedKey nkHealth = new NamespacedKey(MineTinker.getPlugin(), sHealth + toolType.name());

if (ToolType.LEGGINGS.contains(tool.getType()))
meta.addAttributeModifier(Attribute.GENERIC_MAX_HEALTH, new AttributeModifier(nkHealth, level * this.healthPerLevel,
meta.addAttributeModifier(Attribute.MAX_HEALTH, new AttributeModifier(nkHealth, level * this.healthPerLevel,
AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.LEGS));
else //Chestplate and Elytra
meta.addAttributeModifier(Attribute.GENERIC_MAX_HEALTH, new AttributeModifier(nkHealth, level * this.healthPerLevel,
meta.addAttributeModifier(Attribute.MAX_HEALTH, new AttributeModifier(nkHealth, level * this.healthPerLevel,
AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.CHEST));

tool.setItemMeta(meta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ private void effect(@NotNull final Player player, final double damage) {
// Make sure the player can receive the absorption
final ItemMeta meta = chestplate.getItemMeta();
if (meta == null) return;
meta.removeAttributeModifier(Attribute.GENERIC_MAX_ABSORPTION); // Overwrite the old values
meta.addAttributeModifier(Attribute.GENERIC_MAX_ABSORPTION, new AttributeModifier(
meta.removeAttributeModifier(Attribute.MAX_ABSORPTION); // Overwrite the old values
meta.addAttributeModifier(Attribute.MAX_ABSORPTION, new AttributeModifier(
new NamespacedKey(MineTinker.getPlugin(), "generic.max_absorption"), absorption,
AttributeModifier.Operation.ADD_NUMBER, EquipmentSlotGroup.CHEST));
chestplate.setItemMeta(meta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void onDamage(EntityDamageEvent event) {
if (damage > 0) {
event.setDamage(0);
double health = player.getHealth();
player.setHealth(Math.min(health + damage, player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
player.setHealth(Math.min(health + damage, player.getAttribute(Attribute.MAX_HEALTH).getValue()));
ChatWriter.logModifier(player, event, this, armor, String.format("Health(%.2f -> %.2f)", health, player.getHealth()));
}
}
Expand Down

0 comments on commit db33587

Please sign in to comment.