From f4bf70032a45b4daa7805ca38f2d820645dc9a6b Mon Sep 17 00:00:00 2001 From: nea Date: Fri, 29 Jul 2022 20:51:53 +0200 Subject: no arch --- .../notenoughupdates/rei/SBItemEntryDefinition.kt | 98 ++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt (limited to 'src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt') diff --git a/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt new file mode 100644 index 0000000..6726b4f --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/rei/SBItemEntryDefinition.kt @@ -0,0 +1,98 @@ +package moe.nea.notenoughupdates.rei + +import com.mojang.blaze3d.vertex.PoseStack +import io.github.moulberry.repo.data.NEUItem +import me.shedaniel.math.Point +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.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 moe.nea.notenoughupdates.rei.NEUReiPlugin.Companion.asItemEntry +import moe.nea.notenoughupdates.repo.ItemCache.asItemStack +import moe.nea.notenoughupdates.repo.ItemCache.getResourceLocation +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.TagKey +import net.minecraft.world.item.ItemStack +import java.util.stream.Stream + +object SBItemEntryDefinition : EntryDefinition { + override fun equals(o1: NEUItem?, o2: NEUItem?, context: ComparisonContext?): Boolean { + return o1 == o2 + } + + override fun cheatsAs(entry: EntryStack?, value: NEUItem?): ItemStack? { + return value?.asItemStack() + } + + override fun getValueType(): Class = NEUItem::class.java + override fun getType(): EntryType = + EntryType.deferred(NEUReiPlugin.SKYBLOCK_ITEM_TYPE_ID) + + override fun getRenderer(): EntryRenderer = object : EntryRenderer { + override fun render( + entry: EntryStack, + matrices: PoseStack, + bounds: Rectangle, + mouseX: Int, + mouseY: Int, + delta: Float + ) { + VanillaEntryTypes.ITEM.definition.renderer + .render( + entry.asItemEntry(), + matrices, bounds, mouseX, mouseY, delta + ) + } + + override fun getTooltip(entry: EntryStack, tooltipContext: TooltipContext): Tooltip? { + return VanillaEntryTypes.ITEM.definition.renderer + .getTooltip(entry.asItemEntry(), tooltipContext) + } + + } + + override fun getSerializer(): EntrySerializer? { + return null + } + + override fun getTagsFor(entry: EntryStack?, value: NEUItem?): Stream> { + return Stream.empty() + } + + override fun asFormattedText(entry: EntryStack, value: NEUItem): Component { + return VanillaEntryTypes.ITEM.definition.asFormattedText(entry.asItemEntry(), value.asItemStack()) + } + + override fun hash(entry: EntryStack, value: NEUItem, context: ComparisonContext): Long { + return value.skyblockItemId.hashCode().toLong() + } + + override fun wildcard(entry: EntryStack, value: NEUItem): NEUItem { + return value + } + + override fun normalize(entry: EntryStack, value: NEUItem): NEUItem { + return value + } + + override fun copy(entry: EntryStack?, value: NEUItem): NEUItem { + return value + } + + override fun isEmpty(entry: EntryStack?, value: NEUItem?): Boolean { + return false + } + + override fun getIdentifier(entry: EntryStack?, value: NEUItem): ResourceLocation { + return value.getResourceLocation() + } + + +} -- cgit