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 Aug 19, 2024
2 parents ed86b12 + 2bce0ea commit e9f3db4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
## Changes 🌽
- Fixed yet another potential `NullPointerException` when registering a modded menu.
- Reconciled connector based issue where old player data did not transfer over to a new player.
- Updated the modded datapack to apply some attributes properly to scale.
4 changes: 0 additions & 4 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
MIT License

Copyright (c) 2022 CleverNucleus
<<<<<<< HEAD
Copyright (c) 2024 MerryweatherLost
=======
Copyright (c) 2024 Bare Minimum Studios
>>>>>>> 4.0.0+1.20.1

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ parchment_version=1.20.1:2023.09.03
quilt_mappings_version=23

# Mod Properties
mod_version=4.0.0+1.20.1-beta.3
mod_version=4.0.0+1.20.1-beta.4
maven_group=com.bibireden.playerex
archives_base_name=playerex-directors-cut

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net.minecraft.core.Registry
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.ai.attributes.RangedAttribute
import org.jetbrains.annotations.ApiStatus

object PlayerEXAttributes {
@JvmField
Expand Down Expand Up @@ -74,6 +75,7 @@ object PlayerEXAttributes {
@JvmField
val RANGED_CRITICAL_DAMAGE = register("ranged_crit_damage", 0.0, 0.0, 1_000_000.0)

@ApiStatus.Internal
fun register(path: String, base: Double, min: Double, max: Double): RangedAttribute {
val attribute = RangedAttribute("attribute.name.${PlayerEX.MOD_ID}.$path", base, min, max)
return Registry.register(BuiltInRegistries.ATTRIBUTE, ResourceLocation.tryBuild(PlayerEX.MOD_ID, path)!!, attribute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ class PlayerDataComponent(
* */
private fun tryRemove(key: ResourceLocation): Boolean {
return this.getInstance(key)?.let { (instance, isModifierPresent) ->
if (isModifierPresent) {
instance.removeModifier(PlayerEXModifiers.UUID)
}
if (isModifierPresent) instance.removeModifier(PlayerEXModifiers.UUID)
} != null
}

Expand Down Expand Up @@ -127,7 +125,7 @@ class PlayerDataComponent(
}

override fun reset(percent: Int) {
val partition = if (percent == 0) 0.0 else percent / 100.0
val partition = percent / 100.0

val kept = mutableMapOf<ResourceLocation, Double>()
for ((id, value) in this.modifiers) {
Expand All @@ -136,7 +134,9 @@ class PlayerDataComponent(
}
else {
val retained = value * partition
if (!this.trySet(id, retained)) continue
if (!this.trySet(id, retained)) {
continue
}
kept[id] = retained
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/main/kotlin/com/bibireden/playerex/factory/EventFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.bibireden.playerex.factory
import com.bibireden.data_attributes.api.DataAttributesAPI
import com.bibireden.playerex.PlayerEX
import com.bibireden.playerex.api.attribute.PlayerEXAttributes
import com.bibireden.playerex.components.player.PlayerDataComponent
import com.bibireden.playerex.ext.component
import com.bibireden.playerex.registry.DamageModificationRegistry
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.damagesource.DamageSource
import net.minecraft.world.effect.MobEffects
Expand All @@ -16,7 +18,13 @@ import net.minecraft.world.entity.projectile.AbstractArrow
object EventFactory {
fun reset(oldPlayer: ServerPlayer, newPlayer: ServerPlayer, isAlive: Boolean)
{
newPlayer.component.reset(if (PlayerEX.CONFIG.resetOnDeath) 0 else 100)
val factor = if (PlayerEX.CONFIG.resetOnDeath) 0 else 100
// attempt reconciliation
(oldPlayer.component as PlayerDataComponent).modifiers.forEach { (rl, value) ->
val attr = BuiltInRegistries.ATTRIBUTE[rl] ?: return@forEach
newPlayer.component.set(attr, value.toInt())
}
newPlayer.component.reset(factor)
}

fun healed(entity: LivingEntity, amount: Float): Float
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
{
"id": "spell_power:haste",
"behavior": "Add",
"value": 0.002
"value": 2
}
],
"playerex:focus": [
Expand Down

0 comments on commit e9f3db4

Please sign in to comment.