From 95d1bb99af0258a3e684d58d27d3f9e58058ec7a Mon Sep 17 00:00:00 2001 From: CleverNucleus Date: Mon, 2 Jan 2023 12:27:41 +0000 Subject: [PATCH] Attack Speed Bonus Changed *Now depends on Data Attributes 1.3.0 or greater +Buff version *Changed Dexterity bonus to Attack Speed attribute to be +2% rather than +0.1 flat. This takes advantage of the new multiply type function behaviour. --- gradle.properties | 4 +- .../clevernucleus/playerex/api/ExAPI.java | 10 +++ .../playerex/api/client/ClientUtil.java | 15 ++-- .../data/playerex/attributes/functions.json | 85 +++++++++++++++---- src/main/resources/fabric.mod.json | 2 +- 5 files changed, 91 insertions(+), 25 deletions(-) diff --git a/gradle.properties b/gradle.properties index b75bd85d..9fae94d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,12 @@ minecraft_version=1.18.2 yarn_mappings=1.18.2+build.4 loader_version=0.14.10 -mod_version = 3.2.9 +mod_version = 3.4.0 maven_group = com.github.clevernucleus archives_base_name = playerex fabric_version=0.66.0+1.18.2 -dataattributes_version=1.1.12 +dataattributes_version=1.3.0 opc_version=0.5.2 cardinal_components_version=4.2.0 placeholder_api=1.1.3+1.17.1 diff --git a/src/main/java/com/github/clevernucleus/playerex/api/ExAPI.java b/src/main/java/com/github/clevernucleus/playerex/api/ExAPI.java index 51e64323..aa6ca569 100644 --- a/src/main/java/com/github/clevernucleus/playerex/api/ExAPI.java +++ b/src/main/java/com/github/clevernucleus/playerex/api/ExAPI.java @@ -1,5 +1,6 @@ package com.github.clevernucleus.playerex.api; +import java.util.Collection; import java.util.UUID; import java.util.function.BiFunction; @@ -90,6 +91,15 @@ public static void registerRefundCondition(final BiFunction> getRefundConditions() { + return com.github.clevernucleus.playerex.impl.RefundConditionImpl.get(); + } + private static EntityAttributeSupplier define(final String path) { return EntityAttributeSupplier.of(new Identifier(MODID, path)); } diff --git a/src/main/java/com/github/clevernucleus/playerex/api/client/ClientUtil.java b/src/main/java/com/github/clevernucleus/playerex/api/client/ClientUtil.java index fa1d4b41..555c9300 100644 --- a/src/main/java/com/github/clevernucleus/playerex/api/client/ClientUtil.java +++ b/src/main/java/com/github/clevernucleus/playerex/api/client/ClientUtil.java @@ -6,6 +6,8 @@ import java.util.function.Consumer; import java.util.function.Supplier; +import com.github.clevernucleus.dataattributes.api.attribute.FunctionBehaviour; +import com.github.clevernucleus.dataattributes.api.attribute.IAttributeFunction; import com.github.clevernucleus.dataattributes.api.attribute.IEntityAttribute; import com.github.clevernucleus.dataattributes.api.util.Maths; import com.github.clevernucleus.playerex.api.EntityAttributeSupplier; @@ -47,12 +49,14 @@ public static double displayValue(final Supplier attributeIn, d /** * If the input value is positive, adds the "+" prefix. If the input attribute has the {@link ExAPI#PERCENTAGE_PROPERTY} - * property, appends the "%" suffix. + * property or the input FunctionBehaviour is {@link FunctionBehaviour#MULTIPLY}, appends the "%" suffix. * @param attributeIn + * @param behaviourIn * @param valueIn * @return + * @since 3.4.0 */ - public static String formatValue(final Supplier attributeIn, double valueIn) { + public static String formatValue(final Supplier attributeIn, FunctionBehaviour behaviourIn, double valueIn) { String value = FORMATTING_3.format(valueIn); if(valueIn > 0.0D) { @@ -62,7 +66,7 @@ public static String formatValue(final Supplier attributeIn, do IEntityAttribute attribute = (IEntityAttribute)attributeIn.get(); if(attribute == null) return value; - if(attribute.hasProperty(ExAPI.PERCENTAGE_PROPERTY)) { + if(attribute.hasProperty(ExAPI.PERCENTAGE_PROPERTY) || behaviourIn == FunctionBehaviour.MULTIPLY) { value = value + "%"; } @@ -81,9 +85,10 @@ public static void appendChildrenToTooltip(List tooltip, final Supplier (EntityAttribute)attribute2, value); - String formt = formatValue(() -> (EntityAttribute)attribute2, displ); + String formt = formatValue(() -> (EntityAttribute)attribute2, function.behaviour(), displ); MutableText mutableText = new LiteralText(formt + " "); mutableText.append(new TranslatableText(((EntityAttribute)attribute2).getTranslationKey())); tooltip.add(mutableText.formatted(Formatting.GRAY)); diff --git a/src/main/resources/data/playerex/attributes/functions.json b/src/main/resources/data/playerex/attributes/functions.json index 815f9c42..c913db0b 100644 --- a/src/main/resources/data/playerex/attributes/functions.json +++ b/src/main/resources/data/playerex/attributes/functions.json @@ -1,31 +1,82 @@ { "values": { "playerex:constitution": { - "minecraft:generic.max_health": 1.0, - "minecraft:generic.knockback_resistance": 0.01, - "playerex:poison_resistance": 0.01 + "minecraft:generic.max_health": { + "behaviour": "ADDITION", + "value": 1.0 + }, + "minecraft:generic.knockback_resistance": { + "behaviour": "ADDITION", + "value": 0.01 + }, + "playerex:poison_resistance": { + "behaviour": "ADDITION", + "value": 0.01 + } }, "playerex:strength": { - "minecraft:generic.attack_damage": 0.25, - "minecraft:generic.armor": 0.5, - "playerex:health_regeneration": 0.01 + "minecraft:generic.attack_damage": { + "behaviour": "ADDITION", + "value": 0.25 + }, + "minecraft:generic.armor": { + "behaviour": "ADDITION", + "value": 0.5 + }, + "playerex:health_regeneration": { + "behaviour": "ADDITION", + "value": 0.01 + } }, "playerex:dexterity": { - "minecraft:generic.attack_speed": 0.1, - "playerex:ranged_damage": 0.25, - "playerex:melee_crit_damage": 0.005, - "playerex:lightning_resistance": 0.01 + "minecraft:generic.attack_speed": { + "behaviour": "MULTIPLY", + "value": 0.02 + }, + "playerex:ranged_damage": { + "behaviour": "ADDITION", + "value": 0.25 + }, + "playerex:melee_crit_damage": { + "behaviour": "ADDITION", + "value": 0.005 + }, + "playerex:lightning_resistance": { + "behaviour": "ADDITION", + "value": 0.01 + } }, "playerex:intelligence": { - "playerex:heal_amplification": 0.002, - "playerex:ranged_crit_damage": 0.005, - "playerex:wither_resistance": 0.01 + "playerex:heal_amplification": { + "behaviour": "ADDITION", + "value": 0.002 + }, + "playerex:ranged_crit_damage": { + "behaviour": "ADDITION", + "value": 0.005 + }, + "playerex:wither_resistance": { + "behaviour": "ADDITION", + "value": 0.01 + } }, "playerex:luckiness": { - "minecraft:generic.luck": 0.1, - "playerex:evasion": 0.02, - "playerex:melee_crit_chance": 0.02, - "playerex:ranged_crit_chance": 0.02 + "minecraft:generic.luck": { + "behaviour": "ADDITION", + "value": 0.1 + }, + "playerex:evasion": { + "behaviour": "ADDITION", + "value": 0.02 + }, + "playerex:melee_crit_chance": { + "behaviour": "ADDITION", + "value": 0.02 + }, + "playerex:ranged_crit_chance": { + "behaviour": "ADDITION", + "value": 0.02 + } } } } \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index da4c473d..db849fdf 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -42,7 +42,7 @@ "fabricloader": ">=0.14.10", "fabric": ">=0.66.0", "minecraft": "1.18.2", - "dataattributes": ">=1.1.12", + "dataattributes": ">=1.3.0", "cloth-config": ">=6.0.0", "java": ">=17" }