2019-06-21 20:00:00 +10:00
From 12cdd53f25d09c91b6999e9e298d4672535eaf18 Mon Sep 17 00:00:00 2001
2014-07-28 16:56:04 +10:00
From: md_5 <git@md-5.net>
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.
2014-07-28 17:29:45 +10:00
diff --git a/src/main/java/net/minecraft/server/AttributeRanged.java b/src/main/java/net/minecraft/server/AttributeRanged.java
2019-04-25 12:00:00 +10:00
index 2ffa62f2c..0cbd75f14 100644
2014-07-28 17:29:45 +10:00
--- a/src/main/java/net/minecraft/server/AttributeRanged.java
+++ b/src/main/java/net/minecraft/server/AttributeRanged.java
2016-05-10 21:48:25 +10:00
@@ -5,7 +5,7 @@ import javax.annotation.Nullable;
2014-07-28 17:29:45 +10:00
public class AttributeRanged extends AttributeBase {
private final double a;
2018-07-22 12:00:00 +10:00
- public final double maximum;
+ public double maximum; // Spigot
2014-07-28 17:29:45 +10:00
private String c;
2016-05-10 21:48:25 +10:00
public AttributeRanged(@Nullable IAttribute iattribute, String s, double d0, double d1, double d2) {
2014-07-28 16:56:04 +10:00
diff --git a/src/main/java/net/minecraft/server/GenericAttributes.java b/src/main/java/net/minecraft/server/GenericAttributes.java
2019-04-25 12:00:00 +10:00
index 589af605b..908f11f98 100644
2014-07-28 16:56:04 +10:00
--- a/src/main/java/net/minecraft/server/GenericAttributes.java
+++ b/src/main/java/net/minecraft/server/GenericAttributes.java
2019-04-23 12:00:00 +10:00
@@ -10,17 +10,19 @@ import org.apache.logging.log4j.Logger;
2014-07-28 16:56:04 +10:00
public class GenericAttributes {
2019-04-25 12:00:00 +10:00
private static final Logger LOGGER = LogManager.getLogger();
2019-04-23 12:00:00 +10:00
- public static final IAttribute MAX_HEALTH = (new AttributeRanged((IAttribute) null, "generic.maxHealth", 20.0D, 0.0D, 1024.0D)).a("Max Health").a(true);
2014-11-26 08:27:08 +11:00
+ // Spigot start
2019-04-23 12:00:00 +10:00
+ 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);
2015-05-09 21:23:26 +01:00
public static final IAttribute FOLLOW_RANGE = (new AttributeRanged((IAttribute) null, "generic.followRange", 32.0D, 0.0D, 2048.0D)).a("Follow Range");
2019-04-23 12:00:00 +10:00
public static final IAttribute KNOCKBACK_RESISTANCE = (new AttributeRanged((IAttribute) null, "generic.knockbackResistance", 0.0D, 0.0D, 1.0D)).a("Knockback Resistance");
2015-07-30 17:22:16 +10:00
- public static final IAttribute MOVEMENT_SPEED = (new AttributeRanged((IAttribute) null, "generic.movementSpeed", 0.699999988079071D, 0.0D, 1024.0D)).a("Movement Speed").a(true);
2015-05-09 21:23:26 +01:00
+ 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);
2019-04-23 12:00:00 +10:00
public static final IAttribute FLYING_SPEED = (new AttributeRanged((IAttribute) null, "generic.flyingSpeed", 0.4000000059604645D, 0.0D, 1024.0D)).a("Flying Speed").a(true);
2017-05-14 12:00:00 +10:00
- public static final IAttribute ATTACK_DAMAGE = new AttributeRanged((IAttribute) null, "generic.attackDamage", 2.0D, 0.0D, 2048.0D);
2015-05-09 21:23:26 +01:00
+ public static final IAttribute ATTACK_DAMAGE = new AttributeRanged((IAttribute) null, "generic.attackDamage", 2.0D, 0.0D, org.spigotmc.SpigotConfig.attackDamage);
2019-04-23 12:00:00 +10:00
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);
2014-11-26 08:27:08 +11:00
+ // Spigot end
2014-07-28 16:56:04 +10:00
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
2019-04-30 21:46:22 +10:00
index f465671db..f14fec83d 100644
2014-07-28 16:56:04 +10:00
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
2018-12-28 10:22:10 +11:00
@@ -13,6 +13,8 @@ import java.util.List;
import java.util.Map;
2014-07-28 17:29:45 +10:00
import java.util.Set;
import java.util.logging.Level;
+import net.minecraft.server.AttributeRanged;
+import net.minecraft.server.GenericAttributes;
2018-08-26 12:00:00 +10:00
import net.minecraft.server.IRegistry;
2018-07-15 10:00:00 +10:00
import net.minecraft.server.MinecraftKey;
2014-07-28 17:29:45 +10:00
import net.minecraft.server.MinecraftServer;
2018-12-28 10:22:10 +11:00
@@ -343,4 +345,17 @@ public class SpigotConfig
2014-07-28 16:56:04 +10:00
{
2016-03-26 14:16:36 +11:00
movedTooQuicklyMultiplier = getDouble( "settings.moved-too-quickly-multiplier", 10.0D );
2014-07-28 16:56:04 +10:00
}
+
2014-07-28 17:03:52 +10:00
+ public static double maxHealth = 2048;
+ public static double movementSpeed = 2048;
+ public static double attackDamage = 2048;
2014-07-28 16:56:04 +10:00
+ private static void attributeMaxes()
+ {
2014-07-28 17:03:52 +10:00
+ maxHealth = getDouble( "settings.attribute.maxHealth.max", maxHealth );
2019-04-23 12:00:00 +10:00
+ ( (AttributeRanged) GenericAttributes.MAX_HEALTH ).maximum = maxHealth;
2014-07-28 17:03:52 +10:00
+ movementSpeed = getDouble( "settings.attribute.movementSpeed.max", movementSpeed );
2018-07-22 12:00:00 +10:00
+ ( (AttributeRanged) GenericAttributes.MOVEMENT_SPEED ).maximum = movementSpeed;
2014-07-28 17:03:52 +10:00
+ attackDamage = getDouble( "settings.attribute.attackDamage.max", attackDamage );
2018-07-22 12:00:00 +10:00
+ ( (AttributeRanged) GenericAttributes.ATTACK_DAMAGE ).maximum = attackDamage;
2014-07-28 16:56:04 +10:00
+ }
}
--
2019-04-23 09:33:25 +10:00
2.20.1
2014-07-28 16:56:04 +10:00