mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 18:37:42 +01:00
Add attribute clamping and armor limit config
This commit is contained in:
@@ -1,61 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|
||||||
Date: Thu, 27 Oct 2022 23:12:45 -0400
|
|
||||||
Subject: [PATCH] Add attribute clamping and armor limit config
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/damagesource/CombatRules.java b/net/minecraft/world/damagesource/CombatRules.java
|
|
||||||
index 064c1e33f3feee77837bb57887877ae1ca39548d..ffd009bca3fdbfd0b14df78072ef8d472a57cd65 100644
|
|
||||||
--- a/net/minecraft/world/damagesource/CombatRules.java
|
|
||||||
+++ b/net/minecraft/world/damagesource/CombatRules.java
|
|
||||||
@@ -15,7 +15,7 @@ public class CombatRules {
|
|
||||||
|
|
||||||
public static float getDamageAfterAbsorb(LivingEntity armorWearer, float damageAmount, DamageSource damageSource, float armor, float armorToughness) {
|
|
||||||
float f = 2.0F + armorToughness / 4.0F;
|
|
||||||
- float g = Mth.clamp(armor - damageAmount / f, armor * 0.2F, 20.0F);
|
|
||||||
+ float g = Mth.clamp(armor - damageAmount / f, armor * 0.2F, org.purpurmc.purpur.PurpurConfig.limitArmor ? 20F : Float.MAX_VALUE); // Purpur
|
|
||||||
float h = g / 25.0F;
|
|
||||||
ItemStack itemStack = damageSource.getWeaponItem();
|
|
||||||
float i;
|
|
||||||
@@ -30,7 +30,7 @@ public class CombatRules {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getDamageAfterMagicAbsorb(float damageDealt, float protection) {
|
|
||||||
- float f = Mth.clamp(protection, 0.0F, 20.0F);
|
|
||||||
+ float f = Mth.clamp(protection, 0.0F, org.purpurmc.purpur.PurpurConfig.limitArmor ? 20F : Float.MAX_VALUE); // Purpur
|
|
||||||
return damageDealt * (1.0F - f / 25.0F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/net/minecraft/world/entity/ai/attributes/RangedAttribute.java b/net/minecraft/world/entity/ai/attributes/RangedAttribute.java
|
|
||||||
index f0703302e7dbbda88de8c648d20d87c55ed9b1e0..a913ebabaa5f443afa987b972355a8f8d1723c78 100644
|
|
||||||
--- a/net/minecraft/world/entity/ai/attributes/RangedAttribute.java
|
|
||||||
+++ b/net/minecraft/world/entity/ai/attributes/RangedAttribute.java
|
|
||||||
@@ -29,6 +29,7 @@ public class RangedAttribute extends Attribute {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double sanitizeValue(double value) {
|
|
||||||
+ if (!org.purpurmc.purpur.PurpurConfig.clampAttributes) return Double.isNaN(value) ? this.minValue : value; // Purpur
|
|
||||||
return Double.isNaN(value) ? this.minValue : Mth.clamp(value, this.minValue, this.maxValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
index 8cbce0cb8fa811edf01af3dbdf69c8abd795b348..535c7d6298ca62ea1bf808ac8deec1d2381b3831 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
|
||||||
@@ -507,6 +507,16 @@ public class PurpurConfig {
|
|
||||||
fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public static boolean clampAttributes = true;
|
|
||||||
+ private static void clampAttributes() {
|
|
||||||
+ clampAttributes = getBoolean("settings.clamp-attributes", clampAttributes);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean limitArmor = true;
|
|
||||||
+ private static void limitArmor() {
|
|
||||||
+ limitArmor = getBoolean("settings.limit-armor", limitArmor);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
private static void blastResistanceSettings() {
|
|
||||||
getMap("settings.blast-resistance-overrides", Collections.emptyMap()).forEach((blockId, value) -> {
|
|
||||||
Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId));
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
--- a/net/minecraft/world/damagesource/CombatRules.java
|
||||||
|
+++ b/net/minecraft/world/damagesource/CombatRules.java
|
||||||
|
@@ -15,7 +_,7 @@
|
||||||
|
|
||||||
|
public static float getDamageAfterAbsorb(LivingEntity entity, float damage, DamageSource damageSource, float armorValue, float armorToughness) {
|
||||||
|
float f = 2.0F + armorToughness / 4.0F;
|
||||||
|
- float f1 = Mth.clamp(armorValue - damage / f, armorValue * 0.2F, 20.0F);
|
||||||
|
+ float f1 = Mth.clamp(armorValue - damage / f, armorValue * 0.2F, org.purpurmc.purpur.PurpurConfig.limitArmor ? 20F : Float.MAX_VALUE); // Purpur - Add attribute clamping and armor limit config
|
||||||
|
float f2 = f1 / 25.0F;
|
||||||
|
ItemStack weaponItem = damageSource.getWeaponItem();
|
||||||
|
float f3;
|
||||||
|
@@ -30,7 +_,7 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float getDamageAfterMagicAbsorb(float damage, float enchantModifiers) {
|
||||||
|
- float f = Mth.clamp(enchantModifiers, 0.0F, 20.0F);
|
||||||
|
+ float f = Mth.clamp(enchantModifiers, 0.0F, org.purpurmc.purpur.PurpurConfig.limitArmor ? 20F : Float.MAX_VALUE); // Purpur - Add attribute clamping and armor limit config
|
||||||
|
return damage * (1.0F - f / 25.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
--- a/net/minecraft/world/entity/ai/attributes/RangedAttribute.java
|
||||||
|
+++ b/net/minecraft/world/entity/ai/attributes/RangedAttribute.java
|
||||||
|
@@ -29,6 +_,7 @@
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double sanitizeValue(double value) {
|
||||||
|
+ if (!org.purpurmc.purpur.PurpurConfig.clampAttributes) return Double.isNaN(value) ? this.minValue : value; // Purpur - Add attribute clamping and armor limit config
|
||||||
|
return Double.isNaN(value) ? this.minValue : Mth.clamp(value, this.minValue, this.maxValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -503,6 +503,16 @@ public class PurpurConfig {
|
|||||||
fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer);
|
fixProjectileLootingTransfer = getBoolean("settings.fix-projectile-looting-transfer", fixProjectileLootingTransfer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean clampAttributes = true;
|
||||||
|
private static void clampAttributes() {
|
||||||
|
clampAttributes = getBoolean("settings.clamp-attributes", clampAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean limitArmor = true;
|
||||||
|
private static void limitArmor() {
|
||||||
|
limitArmor = getBoolean("settings.limit-armor", limitArmor);
|
||||||
|
}
|
||||||
|
|
||||||
private static void blastResistanceSettings() {
|
private static void blastResistanceSettings() {
|
||||||
getMap("settings.blast-resistance-overrides", Collections.emptyMap()).forEach((blockId, value) -> {
|
getMap("settings.blast-resistance-overrides", Collections.emptyMap()).forEach((blockId, value) -> {
|
||||||
Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId));
|
Block block = BuiltInRegistries.BLOCK.getValue(ResourceLocation.parse(blockId));
|
||||||
|
|||||||
Reference in New Issue
Block a user