Skip to content

Commit

Permalink
Attack Speed Bonus Changed
Browse files Browse the repository at this point in the history
*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.
  • Loading branch information
CleverNucleus committed Jan 2, 2023
1 parent a72f7c8 commit 95d1bb9
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 25 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/github/clevernucleus/playerex/api/ExAPI.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.clevernucleus.playerex.api;

import java.util.Collection;
import java.util.UUID;
import java.util.function.BiFunction;

Expand Down Expand Up @@ -90,6 +91,15 @@ public static void registerRefundCondition(final BiFunction<PlayerData, PlayerEn
com.github.clevernucleus.playerex.impl.RefundConditionImpl.add(refundCondition);
}

/**
* @return Returns all the registered refund conditions. Note that while this is mutable and backed by the original registry,
* you should avoid modification and treat as read-only!
* @since 3.4.0
*/
public static Collection<BiFunction<PlayerData, PlayerEntity, Double>> getRefundConditions() {
return com.github.clevernucleus.playerex.impl.RefundConditionImpl.get();
}

private static EntityAttributeSupplier define(final String path) {
return EntityAttributeSupplier.of(new Identifier(MODID, path));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,12 +49,14 @@ public static double displayValue(final Supplier<EntityAttribute> 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<EntityAttribute> attributeIn, double valueIn) {
public static String formatValue(final Supplier<EntityAttribute> attributeIn, FunctionBehaviour behaviourIn, double valueIn) {
String value = FORMATTING_3.format(valueIn);

if(valueIn > 0.0D) {
Expand All @@ -62,7 +66,7 @@ public static String formatValue(final Supplier<EntityAttribute> 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 + "%";
}

Expand All @@ -81,9 +85,10 @@ public static void appendChildrenToTooltip(List<Text> tooltip, final Supplier<En

for(var child : attribute.children().entrySet()) {
IEntityAttribute attribute2 = child.getKey();
double value = child.getValue();
IAttributeFunction function = child.getValue();
double value = function.value() * (function.behaviour() == FunctionBehaviour.MULTIPLY ? 100.0D : 1.0D);
double displ = displayValue(() -> (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));
Expand Down
85 changes: 68 additions & 17 deletions src/main/resources/data/playerex/attributes/functions.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 95d1bb9

Please sign in to comment.