Skip to content

Commit

Permalink
Ready for 2.0.0+1.20.1-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
bibi-reden committed Jun 28, 2024
1 parent df16ef6 commit 2e65b43
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
9 changes: 5 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Double> k = new AtomicReference<>(0.0D);
AtomicReference<Double> v = new AtomicReference<>(0.0D);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`. */
Expand All @@ -44,11 +44,11 @@ class OverridesConfigModel {
@JvmField
val ENDEC: Endec<AttributeOverrideConfig> = 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() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Identifier> = CodecUtils.ofCodec(Identifier.CODEC)
val IDENTIFIER: Endec<Identifier> = Endec.STRING.xmap(::Identifier, Identifier::toString)
}

0 comments on commit 2e65b43

Please sign in to comment.