diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cfe4a51..d6b8bf38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,3 @@ ## Changes 🌽 -- Made skill point increases separate to the actual attribute value. - - As for increases to skills like **Constitution** that come from somewhere else, it will be tacked on the right in square brackets. \ No newline at end of file +- Resolved an issue with `ON_TICK` and renamed it to `ON_EVERY_SECOND`. + - The counter to reset was not present, but this has been fixed now. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 10504d36..a9cd4dd3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,14 +10,14 @@ loader=fabric minecraft_version=1.20.1 loader_version=0.15.11 fabric_kotlin_version=1.12.0+kotlin.2.0.10 -loom_version=1.7-SNAPSHOT +loom_version=1.8-SNAPSHOT # Mappings parchment_version=1.20.1:2023.09.03 quilt_mappings_version=23 # Mod Properties -mod_version=4.0.0+1.20.1-beta.10 +mod_version=4.0.0+1.20.1-beta.11 maven_group=com.bibireden.playerex archives_base_name=playerex-directors-cut @@ -31,7 +31,7 @@ ranged_weapon_api_version=1.1.2+1.20.1 # in-house opc_version=2.0.0+1.20.1-beta.4-fabric -data_attributes_version=2.0.1+1.20.1-fabric +data_attributes_version=2.0.2+1.20.1-fabric # owo owo_version=0.11.2+1.20 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a4413138..9355b415 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/client/kotlin/com/bibireden/playerex/ui/PlayerEXScreen.kt b/src/client/kotlin/com/bibireden/playerex/ui/PlayerEXScreen.kt index d4412c51..e8b17622 100644 --- a/src/client/kotlin/com/bibireden/playerex/ui/PlayerEXScreen.kt +++ b/src/client/kotlin/com/bibireden/playerex/ui/PlayerEXScreen.kt @@ -19,6 +19,7 @@ import io.wispforest.owo.ui.component.* import io.wispforest.owo.ui.container.FlowLayout import io.wispforest.owo.ui.core.Component as OwoComponent import io.wispforest.owo.ui.core.Easing +import io.wispforest.owo.ui.core.OwoUIDrawContext import io.wispforest.owo.ui.core.ParentComponent import io.wispforest.owo.ui.core.Sizing import io.wispforest.owo.util.EventSource @@ -52,8 +53,6 @@ class PlayerEXScreen : BaseUIModelScreen<FlowLayout>(FlowLayout::class.java, Dat /** Whenever the level attribute gets modified, and on initialization of the screen, this will be called. */ fun onLevelUpdated(level: Int) { - val root = this.uiAdapter.rootComponent - currentLevel.apply { text(Component.translatable("playerex.ui.current_level", player.level.toInt(), PlayerEXUtil.getRequiredXpForNextLevel(player))) } diff --git a/src/client/kotlin/com/bibireden/playerex/ui/menus/PlayerEXAttributesMenu.kt b/src/client/kotlin/com/bibireden/playerex/ui/menus/PlayerEXAttributesMenu.kt index 05816950..8eeec712 100644 --- a/src/client/kotlin/com/bibireden/playerex/ui/menus/PlayerEXAttributesMenu.kt +++ b/src/client/kotlin/com/bibireden/playerex/ui/menus/PlayerEXAttributesMenu.kt @@ -1,9 +1,8 @@ package com.bibireden.playerex.ui.menus -import com.bibireden.data_attributes.api.DataAttributesAPI import com.bibireden.data_attributes.api.attribute.EntityAttributeSupplier import com.bibireden.playerex.api.attribute.PlayerEXAttributes -import com.bibireden.playerex.components.player.IPlayerDataComponent +import com.bibireden.playerex.ext.component import com.bibireden.playerex.ext.id import com.bibireden.playerex.ui.PlayerEXScreen import com.bibireden.playerex.ui.childById @@ -75,16 +74,16 @@ class PlayerEXAttributesMenu : MenuComponent(algorithm = Algorithm.HORIZONTAL) { } } - private fun onInputFieldUpdated(player: Player, component: IPlayerDataComponent) { + private fun onInputFieldUpdated(player: Player) { this.childById(FlowLayout::class, "attributes")?.childById(TextBoxComponent::class, "input")?.also { val result = it.value.toDoubleOrNull() ?: return@also this.forEachDescendant { descendant -> if (descendant is AttributeButtonComponent) { val max = descendant.attribute.`data_attributes$max`() - val current = component.get(descendant.attribute) + val current = player.component.get(descendant.attribute) when (descendant.type) { - PlayerEXScreen.ButtonType.Add -> descendant.active(result > 0 && component.skillPoints >= result && (current + result) <= max) - PlayerEXScreen.ButtonType.Remove -> descendant.active(result > 0 && component.refundablePoints > 0 && (current - result >= 0)) + PlayerEXScreen.ButtonType.Add -> descendant.active(result > 0 && player.component.skillPoints >= result && (current + result) <= max) + PlayerEXScreen.ButtonType.Remove -> descendant.active(result > 0 && player.component.refundablePoints > 0 && (current - result >= 0)) } } } @@ -101,14 +100,14 @@ class PlayerEXAttributesMenu : MenuComponent(algorithm = Algorithm.HORIZONTAL) { Sizing.fill(100), Containers.verticalFlow(Sizing.fill(100), Sizing.content()).apply { child(Containers.horizontalFlow(Sizing.fill(100), Sizing.content(2)).apply { - child(Components.label(Component.translatable("playerex.ui.category.primary_attributes"))) + child(Components.label(Component.translatable("playerex.ui.category.attributes"))) child( Components.textBox(Sizing.fixed(27)) .text("1") .also { it.setMaxLength(4) it.setFilter(InputHelper::isUIntInput) - it.onChanged().subscribe { onInputFieldUpdated(player, component) } + it.onChanged().subscribe { onInputFieldUpdated(player) } } .verticalSizing(Sizing.fixed(10)) .positioning(Positioning.relative(100, 0)) @@ -152,11 +151,11 @@ class PlayerEXAttributesMenu : MenuComponent(algorithm = Algorithm.HORIZONTAL) { padding(Insets.both(8, 8)) onAttributeUpdate() - onInputFieldUpdated(player, component) + onInputFieldUpdated(player) onAttributeUpdated.subscribe { _, _ -> onAttributeUpdate() - onInputFieldUpdated(player, component) + onInputFieldUpdated(player) } } } \ No newline at end of file diff --git a/src/main/java/com/bibireden/playerex/mixin/LivingEntityMixin.java b/src/main/java/com/bibireden/playerex/mixin/LivingEntityMixin.java index 45f5ee70..a4647e5c 100644 --- a/src/main/java/com/bibireden/playerex/mixin/LivingEntityMixin.java +++ b/src/main/java/com/bibireden/playerex/mixin/LivingEntityMixin.java @@ -49,7 +49,8 @@ public void preventAttack(InteractionHand hand, CallbackInfo ci) { this.playerex_ticks++; } else { - LivingEntityEvents.ON_TICK.invoker().onTick((LivingEntity) (Object) this); + LivingEntityEvents.ON_EVERY_SECOND.invoker().onEverySecond((LivingEntity) (Object) this); + this.playerex_ticks = 0; } } diff --git a/src/main/kotlin/com/bibireden/playerex/PlayerEX.kt b/src/main/kotlin/com/bibireden/playerex/PlayerEX.kt index 0ded06c7..4f701fed 100644 --- a/src/main/kotlin/com/bibireden/playerex/PlayerEX.kt +++ b/src/main/kotlin/com/bibireden/playerex/PlayerEX.kt @@ -69,7 +69,7 @@ object PlayerEX : ModInitializer { ServerPlayerEvents.COPY_FROM.register(EventFactory::reset) LivingEntityEvents.ON_HEAL.register(EventFactory::healed) - LivingEntityEvents.ON_TICK.register(EventFactory::healthRegeneration) + LivingEntityEvents.ON_EVERY_SECOND.register(EventFactory::healthRegeneration) LivingEntityEvents.ON_DAMAGE.register(EventFactory::onDamage) LivingEntityEvents.SHOULD_DAMAGE.register(EventFactory::shouldDamage) diff --git a/src/main/kotlin/com/bibireden/playerex/api/attribute/PlayerEXAttributes.kt b/src/main/kotlin/com/bibireden/playerex/api/attribute/PlayerEXAttributes.kt index 8c7415d6..38230a04 100644 --- a/src/main/kotlin/com/bibireden/playerex/api/attribute/PlayerEXAttributes.kt +++ b/src/main/kotlin/com/bibireden/playerex/api/attribute/PlayerEXAttributes.kt @@ -34,7 +34,7 @@ object PlayerEXAttributes { val FOCUS = register("focus", 0.0, 0.0, 100.0) @JvmField - val HEALTH_REGENERATION = register("health_regeneration", 0.0, 0.0, 1.0) + val HEALTH_REGENERATION = register("health_regeneration", 0.0, 0.0, 1_000_000.0) @JvmField val HEAL_AMPLIFICATION = register("heal_amplification", 0.0, 0.0, 1.0) diff --git a/src/main/kotlin/com/bibireden/playerex/api/event/LivingEntityEvents.kt b/src/main/kotlin/com/bibireden/playerex/api/event/LivingEntityEvents.kt index c8b0041d..3f529563 100644 --- a/src/main/kotlin/com/bibireden/playerex/api/event/LivingEntityEvents.kt +++ b/src/main/kotlin/com/bibireden/playerex/api/event/LivingEntityEvents.kt @@ -32,7 +32,7 @@ object LivingEntityEvents { * Fired once at the end of {@link LivingEntity#tick()}, every 20 ticks (1 second). */ @JvmField - val ON_TICK: Event<Tick> = EventFactory.createArrayBacked(Tick::class.java) { callbacks -> Tick { entity -> callbacks.forEach { it.onTick(entity) } }} + val ON_EVERY_SECOND: Event<OnEverySecond> = EventFactory.createArrayBacked(OnEverySecond::class.java) { callbacks -> OnEverySecond { entity -> callbacks.forEach { it.onEverySecond(entity) } }} /** * Fired before {@link LivingEntity#damage(DamageSource, float)}; allows the amount of damage to be modified before it is used in any way. @@ -67,8 +67,8 @@ object LivingEntityEvents { fun shouldHeal(livingEntity: LivingEntity, original: Float): Boolean } - fun interface Tick { - fun onTick(livingEntity: LivingEntity) + fun interface OnEverySecond { + fun onEverySecond(livingEntity: LivingEntity) } fun interface Damaged { diff --git a/src/main/kotlin/com/bibireden/playerex/factory/EventFactory.kt b/src/main/kotlin/com/bibireden/playerex/factory/EventFactory.kt index 66efceb3..eb5a6883 100644 --- a/src/main/kotlin/com/bibireden/playerex/factory/EventFactory.kt +++ b/src/main/kotlin/com/bibireden/playerex/factory/EventFactory.kt @@ -35,18 +35,10 @@ object EventFactory { fun healthRegeneration(entity: LivingEntity) { if (!entity.level().isClientSide()) { - val healthRegenerationOption = DataAttributesAPI.getValue(PlayerEXAttributes.HEALTH_REGENERATION, entity) - - if (healthRegenerationOption.isPresent) - { - val healthRegeneration = healthRegenerationOption.get() - - if (healthRegeneration > 0.0 && entity.health < entity.maxHealth) - { - entity.heal(healthRegeneration.toFloat()) + DataAttributesAPI.getValue(PlayerEXAttributes.HEALTH_REGENERATION, entity).ifPresent { value -> + if (value > 0.0 && entity.health < entity.maxHealth) { + entity.heal(value.toFloat()) } - - return } } } diff --git a/src/main/resources/assets/playerex/lang/en_us.json b/src/main/resources/assets/playerex/lang/en_us.json index 9948c8ca..a87678f7 100644 --- a/src/main/resources/assets/playerex/lang/en_us.json +++ b/src/main/resources/assets/playerex/lang/en_us.json @@ -13,7 +13,7 @@ "playerex.ui.main.skill_points_header": "SKILL POINTS", "playerex.ui.main.modified_attributes": [ {"text": "❤ ", "color": "#48D19B"}, {"text": "Modified Attributes", "color": "white"} ], - "playerex.ui.category.primary_attributes": "Attributes", + "playerex.ui.category.attributes": "Attributes", "playerex.ui.current_level": [ {"text": "❤ ", "color": "#F0C25E"}, diff --git a/src/main/resources/data/playerex/data_attributes/overrides/stock.json b/src/main/resources/data/playerex/data_attributes/overrides/stock.json index 190724ce..9c3b28a2 100644 --- a/src/main/resources/data/playerex/data_attributes/overrides/stock.json +++ b/src/main/resources/data/playerex/data_attributes/overrides/stock.json @@ -36,10 +36,6 @@ "formula": "Diminished", "format": "Percentage" }, - "playerex:health_regeneration": { - "enabled": true, - "format": "Percentage" - }, "playerex:melee_crit_chance": { "enabled": true, "min": 0.0,