diff --git a/gradle.properties b/gradle.properties index 249bfbfe..6f3b8d9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,7 +10,7 @@ modrinth_version=1.2.1 github_api_version=1.114 # Mod Properties -mod_version=1.10.1-BETA+1.19 +mod_version=1.10.4-BETA+1.19 maven_group=io.github.lucaargolo # Fabric Properties diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt b/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt index 47f13f57..2fe4a67a 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/compat/trinkets/TrinketAbilityRing.kt @@ -19,19 +19,24 @@ class TrinketAbilityRing(settings: Settings, ability: PlayerAbility) : AbilityRi override fun tick(stack: ItemStack, slot: SlotReference, entity: LivingEntity) { if(!entity.world.isClient) { (entity as? PlayerEntityMixed)?.let { + if (isBroken(stack)) { // IF ITS BROKEN FIX IT + unbroken(stack) + enable(stack) + } + try { it.kibe_activeRingsList.removeAll { pair -> pair.second != entity.world.time } } catch (_: Exception) { } it.kibe_activeRingsList.add(Pair(stack, entity.world.time)) - if ((entity.entityWorld != lastworld) && (lastworld != null) && (super.isEnabled(stack))) { //if the entity changed worlds since the ring was initialized and this is NOT on first join, if the ring is not enabled don't bother - lastworld = entity.entityWorld //sets the new most recent world - togglenexttick = 1 - disable(stack) //toggle to disabled because on hard transfers the ring fails to work - } else if (togglenexttick == 1){ //if the value was set signalling a change last tick - togglenexttick = 0 - enable(stack) //toggle back to enabled - } else if (lastworld == null) { //if the world is null, most likely on first join or weird cases - lastworld = entity.entityWorld + + val tag = stack.orCreateNbt + val currentDimension = entity.world.dimension.toString() // CURRENT DIMENSION UPDATE + val storedDimension = tag.getString("dimension") // PREVIOUS DIMENSION STORED + + if (currentDimension != storedDimension) { // PLAYER CHANGED DIMENSIONS REEE + broken(stack) // THIS CRAP BROKEN + disable(stack) + tag.putString("dimension", currentDimension) // STORE NEW DIMENSION } } } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/AbilityRing.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/AbilityRing.kt index 11ac1a63..10d45253 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/AbilityRing.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/AbilityRing.kt @@ -7,8 +7,8 @@ import io.github.lucaargolo.kibe.mixed.PlayerEntityMixed import net.minecraft.entity.Entity import net.minecraft.item.ItemStack import net.minecraft.text.Text + import net.minecraft.world.World -import org.spongepowered.asm.mixin.Shadow @Suppress("LeakingThis") open class AbilityRing(settings: Settings, val ability: PlayerAbility): BooleanItem(settings) { @@ -17,27 +17,27 @@ open class AbilityRing(settings: Settings, val ability: PlayerAbility): BooleanI RINGS.add(this) } - @Shadow - var lastworld: World? = null - - var togglenexttick = 0 - override fun inventoryTick(stack: ItemStack, world: World, entity: Entity, slot: Int, selected: Boolean) { if(!world.isClient) { (entity as? PlayerEntityMixed)?.let { + if (isBroken(stack)) { // IF ITS BROKEN FIX IT + unbroken(stack) + enable(stack) + } + try { it.kibe_activeRingsList.removeAll { pair -> pair.second != world.time } } catch (_: Exception) { } it.kibe_activeRingsList.add(Pair(stack, world.time)) - if ((entity.entityWorld != lastworld) && (lastworld != null) && (super.isEnabled(stack))) { //if the entity changed worlds since the ring was initialized and this is NOT on first join, if the ring is not enabled don't bother - lastworld = entity.entityWorld //sets the new most recent world - togglenexttick = 1 - disable(stack) //toggle to disabled because on hard transfers the ring fails to work - } else if (togglenexttick == 1){ //if the value was set signalling a change last tick - togglenexttick = 0 - enable(stack) //toggle back to enabled - } else if (lastworld == null) { //if the world is null, most likely on first join or weird cases - lastworld = entity.entityWorld + + val tag = stack.orCreateNbt + val currentDimension = world.dimension.toString() // CURRENT DIMENSION UPDATE + val storedDimension = tag.getString("dimension") // PREVIOUS DIMENSION STORED + + if (currentDimension != storedDimension) { // PLAYER CHANGED DIMENSIONS REEE + broken(stack) // THIS CRAP BROKEN + disable(stack) + tag.putString("dimension", currentDimension) // STORE NEW DIMENSION } } } @@ -63,6 +63,7 @@ open class AbilityRing(settings: Settings, val ability: PlayerAbility): BooleanI override fun toggle(stack: ItemStack) { if(super.isEnabled(stack)) { disable(stack) + unbroken(stack) }else{ enable(stack) } diff --git a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/BooleanItem.kt b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/BooleanItem.kt index 41bd76ab..edef0797 100644 --- a/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/BooleanItem.kt +++ b/src/main/kotlin/io/github/lucaargolo/kibe/items/miscellaneous/BooleanItem.kt @@ -21,6 +21,11 @@ open class BooleanItem(settings: Settings): Item(settings) { } else { appendDisabledTooltip(stack, tooltip) } + if (isBroken(stack)) { + appendBrokenTooltip(stack, tooltip) + } else { + appendUnbrokenTooltip(stack, tooltip) + } } override fun use(world: World, player: PlayerEntity, hand: Hand): TypedActionResult { @@ -41,10 +46,22 @@ open class BooleanItem(settings: Settings): Item(settings) { tooltip.add(Text.translatable("tooltip.kibe.shift2disable")) } + open fun appendBrokenTooltip(stack: ItemStack, tooltip: MutableList) { + tooltip.add(Text.translatable("Broken")) + } + + open fun appendUnbrokenTooltip(stack: ItemStack, tooltip: MutableList) { + tooltip.add(Text.translatable("Unbroken")) + } + open fun isEnabled(stack: ItemStack): Boolean { return stack.nbt?.getBoolean(ENABLED) ?: false } + open fun isBroken(stack: ItemStack): Boolean { + return stack.nbt?.getBoolean(BROKEN) ?: false + } + open fun enable(stack: ItemStack) { stack.orCreateNbt.putBoolean(ENABLED, true) } @@ -53,6 +70,14 @@ open class BooleanItem(settings: Settings): Item(settings) { stack.orCreateNbt.putBoolean(ENABLED, false) } + open fun broken(stack: ItemStack) { + stack.orCreateNbt.putBoolean(BROKEN, true) + } + + open fun unbroken(stack: ItemStack) { + stack.orCreateNbt.putBoolean(BROKEN, false) + } + open fun toggle(stack: ItemStack) { if(isEnabled(stack)) { disable(stack) @@ -63,6 +88,7 @@ open class BooleanItem(settings: Settings): Item(settings) { companion object { const val ENABLED = "enabled" + const val BROKEN = "broken" } } \ No newline at end of file