Add parents to collapisble entries

This commit is contained in:
nea
2023-05-04 15:54:56 +02:00
parent 4053a2995e
commit 60ecfedf46
4 changed files with 24 additions and 6 deletions

View File

@@ -2,16 +2,18 @@ package moe.nea.notenoughupdates.rei
import io.github.moulberry.repo.data.NEUItem import io.github.moulberry.repo.data.NEUItem
import me.shedaniel.rei.api.client.plugins.REIClientPlugin import me.shedaniel.rei.api.client.plugins.REIClientPlugin
import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry
import me.shedaniel.rei.api.client.registry.entry.EntryRegistry import me.shedaniel.rei.api.client.registry.entry.EntryRegistry
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry
import me.shedaniel.rei.api.common.entry.EntryStack import me.shedaniel.rei.api.common.entry.EntryStack
import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.text.Text
import net.minecraft.util.Identifier import net.minecraft.util.Identifier
import moe.nea.notenoughupdates.repo.ItemCache
import moe.nea.notenoughupdates.repo.ItemCache.asItemStack import moe.nea.notenoughupdates.repo.ItemCache.asItemStack
import moe.nea.notenoughupdates.repo.RepoManager import moe.nea.notenoughupdates.repo.RepoManager
import moe.nea.notenoughupdates.util.SkyblockId
class NEUReiPlugin : REIClientPlugin { class NEUReiPlugin : REIClientPlugin {
@@ -28,6 +30,16 @@ class NEUReiPlugin : REIClientPlugin {
registry.register(SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition) registry.register(SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition)
} }
override fun registerCollapsibleEntries(registry: CollapsibleEntryRegistry) {
RepoManager.neuRepo.constants.parents.parents
.forEach { (parent, children) ->
registry.group(
SkyblockId(parent).identifier,
Text.literal(RepoManager.getNEUItem(SkyblockId(parent))?.displayName ?: parent),
(children + parent).map { SBItemEntryDefinition.getEntry(RepoManager.getNEUItem(SkyblockId(it))) })
}
}
override fun registerScreens(registry: ScreenRegistry) { override fun registerScreens(registry: ScreenRegistry) {
registry.registerFocusedStack(SkyblockItemIdFocusedStackProvider) registry.registerFocusedStack(SkyblockItemIdFocusedStackProvider)
} }

View File

@@ -68,5 +68,7 @@ object SBItemEntryDefinition : EntryDefinition<NEUItem> {
return value?.getIdentifier() ?: Identifier.of("skyblockitem", "null")!! return value?.getIdentifier() ?: Identifier.of("skyblockitem", "null")!!
} }
fun getEntry(neuItem: NEUItem?) = EntryStack.of(this, neuItem)
} }

View File

@@ -21,11 +21,10 @@ import net.minecraft.item.Items
import net.minecraft.nbt.NbtCompound import net.minecraft.nbt.NbtCompound
import net.minecraft.nbt.NbtOps import net.minecraft.nbt.NbtOps
import net.minecraft.text.Text import net.minecraft.text.Text
import net.minecraft.util.Identifier
import moe.nea.notenoughupdates.NotEnoughUpdates import moe.nea.notenoughupdates.NotEnoughUpdates
import moe.nea.notenoughupdates.mixins.accessor.AccessorDataFixTypes
import moe.nea.notenoughupdates.util.LegacyTagParser import moe.nea.notenoughupdates.util.LegacyTagParser
import moe.nea.notenoughupdates.util.appendLore import moe.nea.notenoughupdates.util.appendLore
import moe.nea.notenoughupdates.util.skyblockId
object ItemCache : IReloadable { object ItemCache : IReloadable {
val dfuLog = Path.of("logs/dfulog.txt") val dfuLog = Path.of("logs/dfulog.txt")
@@ -91,8 +90,7 @@ object ItemCache : IReloadable {
return s return s
} }
fun NEUItem.getIdentifier() = fun NEUItem.getIdentifier() = skyblockId.identifier
Identifier("skyblockitem", skyblockItemId.lowercase().replace(";", "__"))
var job: Job? = null var job: Job? = null

View File

@@ -1,14 +1,20 @@
package moe.nea.notenoughupdates.util package moe.nea.notenoughupdates.util
import io.github.moulberry.repo.data.NEUItem
import io.github.moulberry.repo.data.Rarity import io.github.moulberry.repo.data.Rarity
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.nbt.NbtCompound import net.minecraft.nbt.NbtCompound
import net.minecraft.util.Identifier
@JvmInline @JvmInline
value class SkyblockId(val neuItem: String) value class SkyblockId(val neuItem: String) {
val identifier get() = Identifier("skyblockitem", neuItem.lowercase().replace(";", "__"))
}
val NEUItem.skyblockId get() = SkyblockId(skyblockItemId)
@Serializable @Serializable
data class HypixelPetInfo( data class HypixelPetInfo(