From c41576caedc3df872e943ee014ee482b4c74c20f Mon Sep 17 00:00:00 2001 From: CleverNucleus Date: Sat, 3 Jul 2021 16:36:35 +0100 Subject: [PATCH] Bug fixes +Fixed issue with CaelusAPI and Icarus +Likely fixed issue with BetterEnd, but hard to test as unfamiliar with the mod. +Exposed some functions in the API since I need them in other mods. +Fixed issue with preliminary RelicEx refund points issue: you could refund attributes added by trinket items, use those skillpoints to skill something else, then reequip the same trinket and regain those attributes. Fixed now. +Incremented version --- gradle.properties | 2 +- .../playerex/api/attribute/AttributeData.java | 5 +++++ .../playerex/client/gui/AttributesPage.java | 3 ++- .../playerex/impl/attribute/AttributeDataManager.java | 9 +++++---- .../attributes/generic.blindness_resistance.json | 10 ++++++++++ .../minecraft/attributes/caelus.elytra_flight.json | 10 ++++++++++ src/main/resources/fabric.mod.json | 2 +- 7 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/data/betterend/attributes/generic.blindness_resistance.json create mode 100644 src/main/resources/data/minecraft/attributes/caelus.elytra_flight.json diff --git a/gradle.properties b/gradle.properties index ed7df8a5..de8c2918 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.jvmargs=-Xmx2G loader_version=0.11.3 # Mod Properties - mod_version = 2.0.2 + mod_version = 2.0.3 maven_group = com.github.clevernucleus archives_base_name = playerex diff --git a/src/main/java/com/github/clevernucleus/playerex/api/attribute/AttributeData.java b/src/main/java/com/github/clevernucleus/playerex/api/attribute/AttributeData.java index 2a5afbbb..f5138590 100644 --- a/src/main/java/com/github/clevernucleus/playerex/api/attribute/AttributeData.java +++ b/src/main/java/com/github/clevernucleus/playerex/api/attribute/AttributeData.java @@ -11,6 +11,11 @@ */ public interface AttributeData extends Component { + /** + * Resets all attributes to their defaults. requires a sync. + */ + void reset(); + /** * Adds refund points (if allowed). Refund points are clamped above zero. * @param valueIn diff --git a/src/main/java/com/github/clevernucleus/playerex/client/gui/AttributesPage.java b/src/main/java/com/github/clevernucleus/playerex/client/gui/AttributesPage.java index 0b1b9ae8..a801270e 100644 --- a/src/main/java/com/github/clevernucleus/playerex/client/gui/AttributesPage.java +++ b/src/main/java/com/github/clevernucleus/playerex/client/gui/AttributesPage.java @@ -17,6 +17,7 @@ import com.github.clevernucleus.playerex.client.gui.widget.ScreenButtonWidget; import com.github.clevernucleus.playerex.client.network.ClientNetworkHandler; import com.github.clevernucleus.playerex.handler.NetworkHandler.PacketType; +import com.github.clevernucleus.playerex.impl.attribute.AttributeDataManager; import com.mojang.blaze3d.platform.GlStateManager; import net.fabricmc.api.EnvType; @@ -329,7 +330,7 @@ public void drawBackground(MatrixStack matrices, float delta, int mouseX, int mo IPlayerAttribute attribute = this.fromKey(key); if(this.refunds()) { - button.active = this.data.get(attribute) >= 1.0D; + button.active = ((AttributeDataManager)this.data).getValue(attribute) >= 1.0D; } else { button.active = (this.data.get(attribute) < attribute.maxValue()) && (this.data.get(PlayerAttributes.SKILLPOINTS.get()) >= 1.0D); } diff --git a/src/main/java/com/github/clevernucleus/playerex/impl/attribute/AttributeDataManager.java b/src/main/java/com/github/clevernucleus/playerex/impl/attribute/AttributeDataManager.java index 061c956e..832454bb 100644 --- a/src/main/java/com/github/clevernucleus/playerex/impl/attribute/AttributeDataManager.java +++ b/src/main/java/com/github/clevernucleus/playerex/impl/attribute/AttributeDataManager.java @@ -147,10 +147,6 @@ private void applyAttributeModifier(Set recursives, final IPla } } - private double getValue(final IPlayerAttribute keyIn) { - return this.attributes.getOrDefault(keyIn.registryKey(), keyIn.valueFromType()); - } - private void setValue(final IPlayerAttribute keyIn, final double value) { this.attributes.put(keyIn.registryKey(), value); } @@ -170,6 +166,10 @@ private void setAttribute(final IPlayerAttribute keyIn, final double valueIn) { ExAPI.DATA.sync(this.player); } + public double getValue(final IPlayerAttribute keyIn) { + return this.attributes.getOrDefault(keyIn.registryKey(), keyIn.valueFromType()); + } + public void initContainer() { DefaultAttributeContainer.Builder builder = DefaultAttributeContainer.builder(); @@ -206,6 +206,7 @@ public boolean levelled() { return this.levelled; } + @Override public void reset() { this.levelled = false; this.refunds = 0; diff --git a/src/main/resources/data/betterend/attributes/generic.blindness_resistance.json b/src/main/resources/data/betterend/attributes/generic.blindness_resistance.json new file mode 100644 index 00000000..c38ad55e --- /dev/null +++ b/src/main/resources/data/betterend/attributes/generic.blindness_resistance.json @@ -0,0 +1,10 @@ +{ + "type": "GAME", + "uuid": "ed0b99aa-b2f2-4c5e-b135-ecd62ceea26e", + "defaultValue": 0.0, + "minValue": 0.0, + "maxValue": 1.0, + "translationKey": "attribute.name.generic.blindness_resistance", + "properties": {}, + "functions": [] +} \ No newline at end of file diff --git a/src/main/resources/data/minecraft/attributes/caelus.elytra_flight.json b/src/main/resources/data/minecraft/attributes/caelus.elytra_flight.json new file mode 100644 index 00000000..8bd54ccc --- /dev/null +++ b/src/main/resources/data/minecraft/attributes/caelus.elytra_flight.json @@ -0,0 +1,10 @@ +{ + "type": "GAME", + "uuid": "6bfd7b15-d025-4cbc-9949-34df70d90d4c", + "defaultValue": 0.0, + "minValue": 0.0, + "maxValue": 1.0, + "translationKey": "attribute.name.generic.caelus.flight", + "properties": {}, + "functions": [] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 740bc858..d9df544d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "playerex", - "version": "2.0.2", + "version": "2.0.3", "name": "PlayerEx", "description": "Implements a more detailed attributes system with an rpg theme.", "authors": [