Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}
}
}
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemStack> {
Expand All @@ -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<Text>) {
tooltip.add(Text.translatable("Broken"))
}

open fun appendUnbrokenTooltip(stack: ItemStack, tooltip: MutableList<Text>) {
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)
}
Expand All @@ -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)
Expand All @@ -63,6 +88,7 @@ open class BooleanItem(settings: Settings): Item(settings) {

companion object {
const val ENABLED = "enabled"
const val BROKEN = "broken"
}

}