From bca6f44faf1a501893fe6853f28bd343ec036237 Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 28 Jul 2014 16:55:51 +1000 Subject: [PATCH] Allow Attribute Capping. Apply some sensible defaults and allow server owners to customize the maximum values of selected common attributes. diff --git a/src/main/java/net/minecraft/server/AttributeRanged.java b/src/main/java/net/minecraft/server/AttributeRanged.java index 2ffa62f2..0cbd75f1 100644 --- a/src/main/java/net/minecraft/server/AttributeRanged.java +++ b/src/main/java/net/minecraft/server/AttributeRanged.java @@ -5,7 +5,7 @@ import javax.annotation.Nullable; public class AttributeRanged extends AttributeBase { private final double a; - public final double maximum; + public double maximum; // Spigot private String c; public AttributeRanged(@Nullable IAttribute iattribute, String s, double d0, double d1, double d2) { diff --git a/src/main/java/net/minecraft/server/GenericAttributes.java b/src/main/java/net/minecraft/server/GenericAttributes.java index 76ca8b07..6918e96d 100644 --- a/src/main/java/net/minecraft/server/GenericAttributes.java +++ b/src/main/java/net/minecraft/server/GenericAttributes.java @@ -10,17 +10,19 @@ import org.apache.logging.log4j.Logger; public class GenericAttributes { private static final Logger l = LogManager.getLogger(); - public static final IAttribute MAX_HEALTH = (new AttributeRanged((IAttribute) null, "generic.maxHealth", 20.0D, 0.0D, 1024.0D)).a("Max Health").a(true); + // Spigot start + public static final IAttribute MAX_HEALTH = (new AttributeRanged((IAttribute) null, "generic.maxHealth", 20.0D, 0.0D, org.spigotmc.SpigotConfig.maxHealth)).a("Max Health").a(true); public static final IAttribute FOLLOW_RANGE = (new AttributeRanged((IAttribute) null, "generic.followRange", 32.0D, 0.0D, 2048.0D)).a("Follow Range"); public static final IAttribute KNOCKBACK_RESISTANCE = (new AttributeRanged((IAttribute) null, "generic.knockbackResistance", 0.0D, 0.0D, 1.0D)).a("Knockback Resistance"); - public static final IAttribute MOVEMENT_SPEED = (new AttributeRanged((IAttribute) null, "generic.movementSpeed", 0.699999988079071D, 0.0D, 1024.0D)).a("Movement Speed").a(true); + public static final IAttribute MOVEMENT_SPEED = (new AttributeRanged((IAttribute) null, "generic.movementSpeed", 0.699999988079071D, 0.0D, org.spigotmc.SpigotConfig.movementSpeed)).a("Movement Speed").a(true); public static final IAttribute FLYING_SPEED = (new AttributeRanged((IAttribute) null, "generic.flyingSpeed", 0.4000000059604645D, 0.0D, 1024.0D)).a("Flying Speed").a(true); - public static final IAttribute ATTACK_DAMAGE = new AttributeRanged((IAttribute) null, "generic.attackDamage", 2.0D, 0.0D, 2048.0D); + public static final IAttribute ATTACK_DAMAGE = new AttributeRanged((IAttribute) null, "generic.attackDamage", 2.0D, 0.0D, org.spigotmc.SpigotConfig.attackDamage); public static final IAttribute ATTACK_KNOCKBACK = new AttributeRanged((IAttribute) null, "generic.attackKnockback", 0.0D, 0.0D, 5.0D); public static final IAttribute ATTACK_SPEED = (new AttributeRanged((IAttribute) null, "generic.attackSpeed", 4.0D, 0.0D, 1024.0D)).a(true); public static final IAttribute ARMOR = (new AttributeRanged((IAttribute) null, "generic.armor", 0.0D, 0.0D, 30.0D)).a(true); public static final IAttribute ARMOR_TOUGHNESS = (new AttributeRanged((IAttribute) null, "generic.armorToughness", 0.0D, 0.0D, 20.0D)).a(true); public static final IAttribute LUCK = (new AttributeRanged((IAttribute) null, "generic.luck", 0.0D, -1024.0D, 1024.0D)).a(true); + // Spigot end public static NBTTagList a(AttributeMapBase attributemapbase) { NBTTagList nbttaglist = new NBTTagList(); diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java index 4f3211e8..90911ec9 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java @@ -13,6 +13,8 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; +import net.minecraft.server.AttributeRanged; +import net.minecraft.server.GenericAttributes; import net.minecraft.server.IRegistry; import net.minecraft.server.MinecraftKey; import net.minecraft.server.MinecraftServer; @@ -343,4 +345,17 @@ public class SpigotConfig { movedTooQuicklyMultiplier = getDouble( "settings.moved-too-quickly-multiplier", 10.0D ); } + + public static double maxHealth = 2048; + public static double movementSpeed = 2048; + public static double attackDamage = 2048; + private static void attributeMaxes() + { + maxHealth = getDouble( "settings.attribute.maxHealth.max", maxHealth ); + ( (AttributeRanged) GenericAttributes.MAX_HEALTH ).maximum = maxHealth; + movementSpeed = getDouble( "settings.attribute.movementSpeed.max", movementSpeed ); + ( (AttributeRanged) GenericAttributes.MOVEMENT_SPEED ).maximum = movementSpeed; + attackDamage = getDouble( "settings.attribute.attackDamage.max", attackDamage ); + ( (AttributeRanged) GenericAttributes.ATTACK_DAMAGE ).maximum = attackDamage; + } } -- 2.20.1