From 2e65b43766bde866204b758f38a9e5be3bd036be Mon Sep 17 00:00:00 2001 From: Bibi Reden Date: Fri, 28 Jun 2024 02:35:42 -0500 Subject: [PATCH] Ready for 2.0.0+1.20.1-alpha --- build.gradle.kts | 9 +++++---- gradle.properties | 2 +- .../mixin/EntityAttributeInstanceMixin.java | 4 +++- .../config/models/OverridesConfigModel.kt | 12 ++++++------ .../data_attributes/data/EntityAttributeData.kt | 4 ++-- .../bibireden/data_attributes/data/EntityTypeData.kt | 1 - .../com/bibireden/data_attributes/endec/Endecs.kt | 3 +-- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ed20f58f..3b3a3c1b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,8 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + plugins { kotlin("jvm") version "2.0.0" +// id("org.jetbrains.dokka") version "1.9.20" id("fabric-loom") `maven-publish` java @@ -30,10 +33,8 @@ dependencies { } include("io.wispforest:owo-sentinel:${properties["owo_version"]}") - modImplementation("io.wispforest:endec:${properties["endec_version"]}")!!.let(::include) - modImplementation("io.wispforest.endec:gson:${properties["endec_version"]}")!!.let(::include) - modImplementation("io.wispforest.endec:codec:${properties["endec_version"]}")!!.let(::include) - modImplementation("io.wispforest.endec:netty:${properties["endec_version"]}")!!.let(::include) + include("io.wispforest:endec:${properties["endec_version"]}")!!.let(::api) + include("io.wispforest.endec:netty:${properties["endec_version"]}")!!.let(::api) modImplementation("com.terraformersmc:modmenu:${properties["modmenu_version"]}") { exclude("net.fabricmc.fabric-api") diff --git a/gradle.properties b/gradle.properties index 6e7b3b87..389a4c46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ loom_version=1.7-SNAPSHOT minecraft_version=1.20.1 fabric_kotlin_version=1.11.0+kotlin.2.0.0 fabric_api_version=0.92.2+1.20.1 -mod_version=2.0.0+1.20.1 +mod_version=2.0.0+1.20.1-alpha loader=fabric yarn_mappings=1.20.1+build.10 diff --git a/src/main/java/com/bibireden/data_attributes/mixin/EntityAttributeInstanceMixin.java b/src/main/java/com/bibireden/data_attributes/mixin/EntityAttributeInstanceMixin.java index a3cfdc2b..fbac9bbf 100644 --- a/src/main/java/com/bibireden/data_attributes/mixin/EntityAttributeInstanceMixin.java +++ b/src/main/java/com/bibireden/data_attributes/mixin/EntityAttributeInstanceMixin.java @@ -4,7 +4,6 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -import com.bibireden.data_attributes.data.AttributeFunction; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import org.spongepowered.asm.mixin.Final; @@ -83,6 +82,9 @@ private EntityAttribute data_getAttribute(EntityAttribute original) { MutableEntityAttribute attribute = (MutableEntityAttribute) this.getAttribute(); StackingFormula formula = attribute.data_attributes$formula(); + // If the formula is set to Flat and there is no associated container, provide original. + if (formula == StackingFormula.Flat && this.data_containerCallback == null) return original; + AtomicReference k = new AtomicReference<>(0.0D); AtomicReference v = new AtomicReference<>(0.0D); diff --git a/src/main/kotlin/com/bibireden/data_attributes/config/models/OverridesConfigModel.kt b/src/main/kotlin/com/bibireden/data_attributes/config/models/OverridesConfigModel.kt index dd097b88..a5e86285 100644 --- a/src/main/kotlin/com/bibireden/data_attributes/config/models/OverridesConfigModel.kt +++ b/src/main/kotlin/com/bibireden/data_attributes/config/models/OverridesConfigModel.kt @@ -23,16 +23,16 @@ class OverridesConfigModel { @JvmField var enabled: Boolean = true, @JvmField - var min_fallback: Double = 0.0, - @JvmField - var max_fallback: Double = 20.0, - @JvmField var min: Double = 0.0, @JvmField var max: Double = 1000.0, @JvmField var smoothness: Double = 0.0, @JvmField + var min_fallback: Double = 0.0, + @JvmField + var max_fallback: Double = 20.0, + @JvmField var formula: StackingFormula = StackingFormula.Flat ) { /** Calls an override of an `MutableEntityAttribute`. */ @@ -44,11 +44,11 @@ class OverridesConfigModel { @JvmField val ENDEC: Endec = StructEndecBuilder.of( Endec.BOOLEAN.optionalFieldOf("enabled", { it.enabled }, false), - Endec.DOUBLE.optionalFieldOf("min_fallback", { it.min_fallback }, 0.0), - Endec.DOUBLE.optionalFieldOf("max_fallback", { it.max_fallback }, 1_000_000.0), Endec.DOUBLE.optionalFieldOf("min", { it.min }, 0.0), Endec.DOUBLE.optionalFieldOf("max", { it.max }, 1_000_000.0), Endec.DOUBLE.optionalFieldOf("smoothness", { it.smoothness }, 0.0), + Endec.DOUBLE.optionalFieldOf("min_fallback", { it.min_fallback }, 0.0), + Endec.DOUBLE.optionalFieldOf("max_fallback", { it.max_fallback }, 1_000_000.0), Endec.STRING.xmap( { x -> if (x.uppercase() === "DIMINISHED") StackingFormula.Diminished else StackingFormula.Flat }, { x -> x.name.uppercase() } diff --git a/src/main/kotlin/com/bibireden/data_attributes/data/EntityAttributeData.kt b/src/main/kotlin/com/bibireden/data_attributes/data/EntityAttributeData.kt index f40ef410..f82ce233 100644 --- a/src/main/kotlin/com/bibireden/data_attributes/data/EntityAttributeData.kt +++ b/src/main/kotlin/com/bibireden/data_attributes/data/EntityAttributeData.kt @@ -2,8 +2,8 @@ package com.bibireden.data_attributes.data import com.bibireden.data_attributes.DataAttributes import com.bibireden.data_attributes.config.models.OverridesConfigModel.AttributeOverrideConfig +import com.bibireden.data_attributes.endec.Endecs import com.bibireden.data_attributes.mutable.MutableEntityAttribute -import io.wispforest.endec.CodecUtils import io.wispforest.endec.Endec import io.wispforest.endec.impl.StructEndecBuilder import net.minecraft.entity.attribute.EntityAttribute @@ -21,7 +21,7 @@ class EntityAttributeData(val override: AttributeOverrideConfig? = null, val fun @JvmField val ENDEC = StructEndecBuilder.of( AttributeOverrideConfig.ENDEC.nullableOf().fieldOf("override") { it.override }, - Endec.map(CodecUtils.ofCodec(Identifier.CODEC), AttributeFunction.ENDEC).fieldOf("functions") { it.functions }, + Endec.map(Endecs.IDENTIFIER, AttributeFunction.ENDEC).fieldOf("functions") { it.functions }, ::EntityAttributeData, ) } diff --git a/src/main/kotlin/com/bibireden/data_attributes/data/EntityTypeData.kt b/src/main/kotlin/com/bibireden/data_attributes/data/EntityTypeData.kt index 32bc8adb..943a8fc6 100644 --- a/src/main/kotlin/com/bibireden/data_attributes/data/EntityTypeData.kt +++ b/src/main/kotlin/com/bibireden/data_attributes/data/EntityTypeData.kt @@ -2,7 +2,6 @@ package com.bibireden.data_attributes.data import com.bibireden.data_attributes.endec.Endecs import com.bibireden.data_attributes.mutable.MutableDefaultAttributeContainer -import io.wispforest.endec.CodecUtils import io.wispforest.endec.Endec import net.minecraft.entity.attribute.DefaultAttributeContainer import net.minecraft.registry.Registries diff --git a/src/main/kotlin/com/bibireden/data_attributes/endec/Endecs.kt b/src/main/kotlin/com/bibireden/data_attributes/endec/Endecs.kt index 0178d597..9180977f 100644 --- a/src/main/kotlin/com/bibireden/data_attributes/endec/Endecs.kt +++ b/src/main/kotlin/com/bibireden/data_attributes/endec/Endecs.kt @@ -1,10 +1,9 @@ package com.bibireden.data_attributes.endec -import io.wispforest.endec.CodecUtils import io.wispforest.endec.Endec import net.minecraft.util.Identifier object Endecs { @JvmField - val IDENTIFIER: Endec = CodecUtils.ofCodec(Identifier.CODEC) + val IDENTIFIER: Endec = Endec.STRING.xmap(::Identifier, Identifier::toString) } \ No newline at end of file