diff options
author | nea <nea@nea.moe> | 2023-06-12 17:46:41 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-06-12 17:46:41 +0200 |
commit | d4410a67fb43cf467194b67552cdf4b85c6753bd (patch) | |
tree | e86f0b06741cefe44c80e4e607c334ac47eef61d /src/main/kotlin/moe/nea/firmament/rei | |
parent | cd87be6cb3af335b90fe1c92e71bd3e980f3a310 (diff) | |
download | Firmament-d4410a67fb43cf467194b67552cdf4b85c6753bd.tar.gz Firmament-d4410a67fb43cf467194b67552cdf4b85c6753bd.tar.bz2 Firmament-d4410a67fb43cf467194b67552cdf4b85c6753bd.zip |
Add crafting overlay
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/rei')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt | 19 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt | 19 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt b/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt index def73fe..5016d96 100644 --- a/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt +++ b/src/main/kotlin/moe/nea/firmament/rei/FirmamentReiPlugin.kt @@ -24,18 +24,22 @@ 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.client.registry.transfer.TransferHandler +import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry 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.client.gui.screen.ingame.GenericContainerScreen import net.minecraft.item.ItemStack import net.minecraft.text.Text import net.minecraft.util.Identifier +import moe.nea.firmament.features.inventory.CraftingOverlay import moe.nea.firmament.recipes.SBCraftingRecipe import moe.nea.firmament.recipes.SBForgeRecipe -import moe.nea.firmament.repo.ItemCache.asItemStack import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.SkyblockId import moe.nea.firmament.util.skyblockId +import moe.nea.firmament.util.unformattedString class FirmamentReiPlugin : REIClientPlugin { @@ -48,6 +52,19 @@ class FirmamentReiPlugin : REIClientPlugin { val SKYBLOCK_ITEM_TYPE_ID = Identifier("firmament", "skyblockitems") } + override fun registerTransferHandlers(registry: TransferHandlerRegistry) { + registry.register(TransferHandler { context -> + val screen = context.containerScreen + val display = context.display + if (display !is SBCraftingRecipe || screen !is GenericContainerScreen || screen.title?.unformattedString != "Craft Item") { + return@TransferHandler TransferHandler.Result.createNotApplicable() + } + if (context.isActuallyCrafting) + CraftingOverlay.setOverlay(screen, display) + return@TransferHandler TransferHandler.Result.createSuccessful() + }) + } + override fun registerEntryTypes(registry: EntryTypeRegistry) { registry.register(SKYBLOCK_ITEM_TYPE_ID, SBItemEntryDefinition) } diff --git a/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt index 3d54d5f..eac7d01 100644 --- a/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt +++ b/src/main/kotlin/moe/nea/firmament/rei/SBItemEntryDefinition.kt @@ -39,7 +39,10 @@ import moe.nea.firmament.repo.ItemCache import moe.nea.firmament.repo.ItemCache.asItemStack import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.FirmFormatters +import moe.nea.firmament.util.HypixelPetInfo import moe.nea.firmament.util.SkyblockId +import moe.nea.firmament.util.petData +import moe.nea.firmament.util.skyBlockId // TODO: add in extra data like pet info, into this structure data class PetData( @@ -47,6 +50,12 @@ data class PetData( val petId: String, val exp: Double, ) { + companion object { + fun fromHypixel(petInfo: HypixelPetInfo) = PetData( + petInfo.tier, petInfo.type, petInfo.exp, + ) + } + val levelData by lazy { ExpLadders.getExpLadder(petId, rarity).getPetLevel(exp) } } @@ -155,5 +164,13 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> { fun getEntry(ingredient: NEUIngredient): EntryStack<SBItemStack> = getEntry(SkyblockId(ingredient.itemId), count = ingredient.amount.toInt()) - + fun getEntry(stack: ItemStack): EntryStack<SBItemStack> = + getEntry( + SBItemStack( + stack.skyBlockId ?: SkyblockId.NULL, + RepoManager.getNEUItem(stack.skyBlockId ?: SkyblockId.NULL), + stack.count, + petData = stack.petData?.let { PetData.fromHypixel(it) } + ) + ) } |