mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
61 lines
4.6 KiB
Diff
61 lines
4.6 KiB
Diff
From 2d9d238af51b8701c07dec21dabb99ca47fb43d2 Mon Sep 17 00:00:00 2001
|
|
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.
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/GenericAttributes.java b/src/main/java/net/minecraft/world/entity/ai/attributes/GenericAttributes.java
|
|
index ce952036e..0869a2435 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/GenericAttributes.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/GenericAttributes.java
|
|
@@ -6,12 +6,12 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
|
|
|
public class GenericAttributes {
|
|
|
|
- public static final AttributeBase MAX_HEALTH = register("generic.max_health", (new AttributeRanged("attribute.name.generic.max_health", 20.0D, 1.0D, 1024.0D)).setSyncable(true));
|
|
+ public static final AttributeBase MAX_HEALTH = register("generic.max_health", (new AttributeRanged("attribute.name.generic.max_health", 20.0D, 1.0D, org.spigotmc.SpigotConfig.maxHealth)).setSyncable(true));
|
|
public static final AttributeBase FOLLOW_RANGE = register("generic.follow_range", new AttributeRanged("attribute.name.generic.follow_range", 32.0D, 0.0D, 2048.0D));
|
|
public static final AttributeBase KNOCKBACK_RESISTANCE = register("generic.knockback_resistance", new AttributeRanged("attribute.name.generic.knockback_resistance", 0.0D, 0.0D, 1.0D));
|
|
- public static final AttributeBase MOVEMENT_SPEED = register("generic.movement_speed", (new AttributeRanged("attribute.name.generic.movement_speed", 0.699999988079071D, 0.0D, 1024.0D)).setSyncable(true));
|
|
+ public static final AttributeBase MOVEMENT_SPEED = register("generic.movement_speed", (new AttributeRanged("attribute.name.generic.movement_speed", 0.699999988079071D, 0.0D, org.spigotmc.SpigotConfig.movementSpeed)).setSyncable(true));
|
|
public static final AttributeBase FLYING_SPEED = register("generic.flying_speed", (new AttributeRanged("attribute.name.generic.flying_speed", 0.4000000059604645D, 0.0D, 1024.0D)).setSyncable(true));
|
|
- public static final AttributeBase ATTACK_DAMAGE = register("generic.attack_damage", new AttributeRanged("attribute.name.generic.attack_damage", 2.0D, 0.0D, 2048.0D));
|
|
+ public static final AttributeBase ATTACK_DAMAGE = register("generic.attack_damage", new AttributeRanged("attribute.name.generic.attack_damage", 2.0D, 0.0D, org.spigotmc.SpigotConfig.attackDamage));
|
|
public static final AttributeBase ATTACK_KNOCKBACK = register("generic.attack_knockback", new AttributeRanged("attribute.name.generic.attack_knockback", 0.0D, 0.0D, 5.0D));
|
|
public static final AttributeBase ATTACK_SPEED = register("generic.attack_speed", (new AttributeRanged("attribute.name.generic.attack_speed", 4.0D, 0.0D, 1024.0D)).setSyncable(true));
|
|
public static final AttributeBase ARMOR = register("generic.armor", (new AttributeRanged("attribute.name.generic.armor", 0.0D, 0.0D, 30.0D)).setSyncable(true));
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
index 08f6ef8d4..58fb1b92e 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
|
@@ -16,6 +16,8 @@ import java.util.logging.Level;
|
|
import net.minecraft.core.registries.BuiltInRegistries;
|
|
import net.minecraft.resources.MinecraftKey;
|
|
import net.minecraft.server.MinecraftServer;
|
|
+import net.minecraft.world.entity.ai.attributes.AttributeRanged;
|
|
+import net.minecraft.world.entity.ai.attributes.GenericAttributes;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.ChatColor;
|
|
import org.bukkit.command.Command;
|
|
@@ -338,4 +340,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 ).maxValue = maxHealth;
|
|
+ movementSpeed = getDouble( "settings.attribute.movementSpeed.max", movementSpeed );
|
|
+ ( (AttributeRanged) GenericAttributes.MOVEMENT_SPEED ).maxValue = movementSpeed;
|
|
+ attackDamage = getDouble( "settings.attribute.attackDamage.max", attackDamage );
|
|
+ ( (AttributeRanged) GenericAttributes.ATTACK_DAMAGE ).maxValue = attackDamage;
|
|
+ }
|
|
}
|
|
--
|
|
2.34.1
|
|
|