Skip to content

Commit

Permalink
Merge branch '1.20.1/dev' into 1.20.1/fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
bibi-reden committed Oct 24, 2024
2 parents 1a3afd5 + c827092 commit cdd8df7
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 40 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
- 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.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
}
}
}
Expand All @@ -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))
Expand Down Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/bibireden/playerex/PlayerEX.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 3 additions & 11 deletions src/main/kotlin/com/bibireden/playerex/factory/EventFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/playerex/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
"formula": "Diminished",
"format": "Percentage"
},
"playerex:health_regeneration": {
"enabled": true,
"format": "Percentage"
},
"playerex:melee_crit_chance": {
"enabled": true,
"min": 0.0,
Expand Down

0 comments on commit cdd8df7

Please sign in to comment.