aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/rei
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-05-16 01:23:43 +0200
committernea <nea@nea.moe>2023-05-16 01:23:43 +0200
commitead6762eb1c005914b05f9d3c29f334989c67513 (patch)
treecd1409756be2bc4a93195c31d432fef053afe002 /src/main/kotlin/moe/nea/notenoughupdates/rei
parent96c546cc73880a7c502c17aadda6ca84c847692d (diff)
downloadFirmament-ead6762eb1c005914b05f9d3c29f334989c67513.tar.gz
Firmament-ead6762eb1c005914b05f9d3c29f334989c67513.tar.bz2
Firmament-ead6762eb1c005914b05f9d3c29f334989c67513.zip
Replace references to NEU with Firmament
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/rei')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntryRenderer.kt31
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt25
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt73
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt85
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt52
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockItemIdFocusedStackProvider.kt25
6 files changed, 0 insertions, 291 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntryRenderer.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntryRenderer.kt
deleted file mode 100644
index 111aaf7..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntryRenderer.kt
+++ /dev/null
@@ -1,31 +0,0 @@
-package moe.nea.notenoughupdates.rei
-
-import io.github.moulberry.repo.data.NEUItem
-import me.shedaniel.math.Rectangle
-import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer
-import me.shedaniel.rei.api.client.gui.widgets.Tooltip
-import me.shedaniel.rei.api.client.gui.widgets.TooltipContext
-import me.shedaniel.rei.api.common.entry.EntryStack
-import net.minecraft.client.util.math.MatrixStack
-import moe.nea.notenoughupdates.rei.NEUReiPlugin.Companion.asItemEntry
-
-object NEUItemEntryRenderer : EntryRenderer<NEUItem> {
- override fun render(
- entry: EntryStack<NEUItem>,
- matrices: MatrixStack,
- bounds: Rectangle,
- mouseX: Int,
- mouseY: Int,
- delta: Float
- ) {
- matrices.push()
- matrices.translate(0F, 0F, 100F)
- entry.asItemEntry().render(matrices, bounds, mouseX, mouseY, delta)
- matrices.pop()
- }
-
- override fun getTooltip(entry: EntryStack<NEUItem>, tooltipContext: TooltipContext): Tooltip? {
- return entry.asItemEntry().getTooltip(tooltipContext, false)
- }
-
-}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt
deleted file mode 100644
index b6c81a7..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUItemEntrySerializer.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package moe.nea.notenoughupdates.rei
-
-import io.github.moulberry.repo.data.NEUItem
-import me.shedaniel.rei.api.common.entry.EntrySerializer
-import me.shedaniel.rei.api.common.entry.EntryStack
-import net.minecraft.nbt.NbtCompound
-import moe.nea.notenoughupdates.repo.RepoManager
-import moe.nea.notenoughupdates.util.SkyblockId
-
-object NEUItemEntrySerializer : EntrySerializer<NEUItem?> {
- const val SKYBLOCK_ID_ENTRY = "SKYBLOCK_ID"
-
- override fun supportSaving(): Boolean = true
- override fun supportReading(): Boolean = true
-
- override fun read(tag: NbtCompound): NEUItem? {
- return RepoManager.getNEUItem(SkyblockId(tag.getString(SKYBLOCK_ID_ENTRY)))
- }
-
- override fun save(entry: EntryStack<NEUItem?>, value: NEUItem?): NbtCompound {
- return NbtCompound().apply {
- putString(SKYBLOCK_ID_ENTRY, value?.skyblockItemId ?: "null")
- }
- }
-}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
deleted file mode 100644
index 34d98fa..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/NEUReiPlugin.kt
+++ /dev/null
@@ -1,73 +0,0 @@
-package moe.nea.notenoughupdates.rei
-
-import io.github.moulberry.repo.data.NEUItem
-import me.shedaniel.rei.api.client.plugins.REIClientPlugin
-import me.shedaniel.rei.api.client.registry.category.CategoryRegistry
-import me.shedaniel.rei.api.client.registry.display.DisplayRegistry
-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.screen.ScreenRegistry
-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.VanillaEntryTypes
-import net.minecraft.item.ItemStack
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
-import moe.nea.notenoughupdates.recipes.SBCraftingRecipe
-import moe.nea.notenoughupdates.recipes.SBForgeRecipe
-import moe.nea.notenoughupdates.repo.ItemCache.asItemStack
-import moe.nea.notenoughupdates.repo.RepoManager
-import moe.nea.notenoughupdates.util.SkyblockId
-
-
-class NEUReiPlugin : REIClientPlugin {
-
- companion object {
- fun EntryStack<NEUItem>.asItemEntry(): EntryStack<ItemStack> {
- return EntryStack.of(VanillaEntryTypes.ITEM, value.asItemStack())
- }
-
- val SKYBLOCK_ITEM_TYPE_ID = Identifier("notenoughupdates", "skyblockitems")
- }
-
- override fun registerEntryTypes(registry: EntryTypeRegistry) {
- registry.register(SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition)
- }
-
- override fun registerCategories(registry: CategoryRegistry) {
- registry.add(SBCraftingRecipe.Category)
- registry.add(SBForgeRecipe.Category)
- }
-
- override fun registerDisplays(registry: DisplayRegistry) {
- registry.registerDisplayGenerator(
- SBCraftingRecipe.Category.catIdentifier,
- SkyblockCraftingRecipeDynamicGenerator
- )
- registry.registerDisplayGenerator(
- SBForgeRecipe.Category.categoryIdentifier,
- SkyblockForgeRecipeDynamicGenerator
- )
- }
-
- 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) {
- registry.registerFocusedStack(SkyblockItemIdFocusedStackProvider)
- }
-
- override fun registerEntries(registry: EntryRegistry) {
- RepoManager.neuRepo.items?.items?.values?.forEach {
- if (!it.isVanilla)
- registry.addEntry(EntryStack.of(SBItemEntryDefinition, it))
- }
- }
-}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
deleted file mode 100644
index 0b43407..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt
+++ /dev/null
@@ -1,85 +0,0 @@
-package moe.nea.notenoughupdates.rei
-
-import io.github.moulberry.repo.data.NEUIngredient
-import io.github.moulberry.repo.data.NEUItem
-import java.util.stream.Stream
-import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer
-import me.shedaniel.rei.api.common.entry.EntrySerializer
-import me.shedaniel.rei.api.common.entry.EntryStack
-import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext
-import me.shedaniel.rei.api.common.entry.type.EntryDefinition
-import me.shedaniel.rei.api.common.entry.type.EntryType
-import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
-import net.minecraft.item.ItemStack
-import net.minecraft.registry.tag.TagKey
-import net.minecraft.text.Text
-import net.minecraft.util.Identifier
-import moe.nea.notenoughupdates.rei.NEUReiPlugin.Companion.asItemEntry
-import moe.nea.notenoughupdates.repo.ItemCache.asItemStack
-import moe.nea.notenoughupdates.repo.ItemCache.getIdentifier
-import moe.nea.notenoughupdates.repo.RepoManager
-import moe.nea.notenoughupdates.util.SkyblockId
-
-// TODO: allow stackable entries
-object SBItemEntryDefinition : EntryDefinition<NEUItem> {
- override fun equals(o1: NEUItem?, o2: NEUItem?, context: ComparisonContext?): Boolean {
- return o1 === o2
- }
-
- override fun cheatsAs(entry: EntryStack<NEUItem>?, value: NEUItem?): ItemStack {
- return value.asItemStack()
- }
-
- override fun getValueType(): Class<NEUItem> = NEUItem::class.java
- override fun getType(): EntryType<NEUItem> = EntryType.deferred(NEUReiPlugin.SKYBLOCK_ITEM_TYPE_ID)
-
- override fun getRenderer(): EntryRenderer<NEUItem> = NEUItemEntryRenderer
-
- override fun getSerializer(): EntrySerializer<NEUItem?> {
- return NEUItemEntrySerializer
- }
-
- override fun getTagsFor(entry: EntryStack<NEUItem>?, value: NEUItem?): Stream<out TagKey<*>>? {
- return Stream.empty()
- }
-
- override fun asFormattedText(entry: EntryStack<NEUItem>, value: NEUItem): Text {
- return VanillaEntryTypes.ITEM.definition.asFormattedText(entry.asItemEntry(), value.asItemStack())
- }
-
- override fun hash(entry: EntryStack<NEUItem>, value: NEUItem?, context: ComparisonContext): Long {
- // Repo items are immutable, and get replaced entirely when loaded from disk
- return System.identityHashCode(value) * 31L
- }
-
- override fun wildcard(entry: EntryStack<NEUItem>?, value: NEUItem?): NEUItem? {
- return value
- }
-
- override fun normalize(entry: EntryStack<NEUItem>?, value: NEUItem?): NEUItem? {
- return value
- }
-
- override fun copy(entry: EntryStack<NEUItem>?, value: NEUItem?): NEUItem? {
- return value
- }
-
- override fun isEmpty(entry: EntryStack<NEUItem>?, value: NEUItem?): Boolean {
- return false
- }
-
- override fun getIdentifier(entry: EntryStack<NEUItem>?, value: NEUItem?): Identifier {
- return value?.getIdentifier() ?: Identifier.of("skyblockitem", "null")!!
- }
-
- fun getEntry(neuItem: NEUItem?): EntryStack<NEUItem> =
- EntryStack.of(this, neuItem)
-
- fun getEntry(skyblockId: SkyblockId?): EntryStack<NEUItem> =
- EntryStack.of(this, skyblockId?.let { RepoManager.getNEUItem(it) })
-
- fun getEntry(ingredient: NEUIngredient?): EntryStack<NEUItem> =
- getEntry(ingredient?.itemId?.let { SkyblockId(it) })
-
-
-}
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt
deleted file mode 100644
index cc31427..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockCraftingRecipeDynamicGenerator.kt
+++ /dev/null
@@ -1,52 +0,0 @@
-package moe.nea.notenoughupdates.rei
-
-import io.github.moulberry.repo.data.NEUCraftingRecipe
-import io.github.moulberry.repo.data.NEUForgeRecipe
-import io.github.moulberry.repo.data.NEUItem
-import io.github.moulberry.repo.data.NEURecipe
-import java.util.*
-import me.shedaniel.rei.api.client.registry.display.DynamicDisplayGenerator
-import me.shedaniel.rei.api.client.view.ViewSearchBuilder
-import me.shedaniel.rei.api.common.display.Display
-import me.shedaniel.rei.api.common.entry.EntryStack
-import moe.nea.notenoughupdates.recipes.SBCraftingRecipe
-import moe.nea.notenoughupdates.recipes.SBForgeRecipe
-import moe.nea.notenoughupdates.repo.RepoManager
-import moe.nea.notenoughupdates.util.skyblockId
-
-
-val SkyblockCraftingRecipeDynamicGenerator = neuDisplayGenerator<SBCraftingRecipe, NEUCraftingRecipe> {
- SBCraftingRecipe(it)
-}
-
-val SkyblockForgeRecipeDynamicGenerator = neuDisplayGenerator<SBForgeRecipe, NEUForgeRecipe> {
- SBForgeRecipe(it)
-}
-
-inline fun <D : Display, reified T : NEURecipe> neuDisplayGenerator(noinline mapper: (T) -> D) =
- object : DynamicDisplayGenerator<D> {
- override fun getRecipeFor(entry: EntryStack<*>): Optional<List<D>> {
- if (entry.type != SBItemEntryDefinition.type) return Optional.empty()
- val item = entry.castValue<NEUItem>()
- val recipes = RepoManager.getRecipesFor(item.skyblockId)
- val craftingRecipes = recipes.filterIsInstance<T>()
- return Optional.of(craftingRecipes.map(mapper))
- }
-
- override fun generate(builder: ViewSearchBuilder): Optional<List<D>> {
- if (SBCraftingRecipe.Category.catIdentifier !in builder.categories) return Optional.empty()
- return Optional.of(
- RepoManager.getAllRecipes().filterIsInstance<T>().map(mapper)
- .toList()
- )
- }
-
- override fun getUsageFor(entry: EntryStack<*>): Optional<List<D>> {
- if (entry.type != SBItemEntryDefinition.type) return Optional.empty()
- val item = entry.castValue<NEUItem>()
- val recipes = RepoManager.getUsagesFor(item.skyblockId)
- val craftingRecipes = recipes.filterIsInstance<T>()
- return Optional.of(craftingRecipes.map(mapper))
-
- }
- }
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockItemIdFocusedStackProvider.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockItemIdFocusedStackProvider.kt
deleted file mode 100644
index 8592126..0000000
--- a/src/main/kotlin/moe/nea/notenoughupdates/rei/SkyblockItemIdFocusedStackProvider.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-package moe.nea.notenoughupdates.rei
-
-import dev.architectury.event.CompoundEventResult
-import me.shedaniel.math.Point
-import me.shedaniel.rei.api.client.registry.screen.FocusedStackProvider
-import me.shedaniel.rei.api.common.entry.EntryStack
-import moe.nea.notenoughupdates.mixins.accessor.AccessorHandledScreen
-import moe.nea.notenoughupdates.repo.RepoManager
-import moe.nea.notenoughupdates.util.skyBlockId
-import net.minecraft.client.gui.screen.Screen
-import net.minecraft.client.gui.screen.ingame.HandledScreen
-
-object SkyblockItemIdFocusedStackProvider : FocusedStackProvider {
- override fun provide(screen: Screen?, mouse: Point?): CompoundEventResult<EntryStack<*>> {
- if (screen !is HandledScreen<*>) return CompoundEventResult.pass()
- screen as AccessorHandledScreen
- val focusedSlot = screen.focusedSlot_NEU ?: return CompoundEventResult.pass()
- val item = focusedSlot.stack ?: return CompoundEventResult.pass()
- val skyblockId = item.skyBlockId ?: return CompoundEventResult.pass()
- val neuItem = RepoManager.getNEUItem(skyblockId) ?: return CompoundEventResult.interrupt(false, null)
- return CompoundEventResult.interruptTrue(EntryStack.of(SBItemEntryDefinition, neuItem))
- }
-
- override fun getPriority(): Double = 1_000_000.0
-}