WIP: Re-Enable REI
This commit is contained in:
@@ -223,7 +223,7 @@ val explosiveEnhancementSourceSet =
|
|||||||
createIsolatedSourceSet("explosiveEnhancement", isEnabled = false) // TODO: wait for their port
|
createIsolatedSourceSet("explosiveEnhancement", isEnabled = false) // TODO: wait for their port
|
||||||
val wildfireGenderSourceSet = createIsolatedSourceSet("wildfireGender", isEnabled = false) // TODO: wait on their port
|
val wildfireGenderSourceSet = createIsolatedSourceSet("wildfireGender", isEnabled = false) // TODO: wait on their port
|
||||||
val modmenuSourceSet = createIsolatedSourceSet("modmenu", isEnabled = false)
|
val modmenuSourceSet = createIsolatedSourceSet("modmenu", isEnabled = false)
|
||||||
val reiSourceSet = createIsolatedSourceSet("rei", isEnabled = false)
|
val reiSourceSet = createIsolatedSourceSet("rei")
|
||||||
val moulconfigSourceSet = createIsolatedSourceSet("moulconfig", isEnabled = false)
|
val moulconfigSourceSet = createIsolatedSourceSet("moulconfig", isEnabled = false)
|
||||||
val customTexturesSourceSet = createIsolatedSourceSet("texturePacks", "texturePacks")
|
val customTexturesSourceSet = createIsolatedSourceSet("texturePacks", "texturePacks")
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,7 @@
|
|||||||
|
|
||||||
package moe.nea.firmament.compat.rei
|
package moe.nea.firmament.compat.rei
|
||||||
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.DstFactor
|
|
||||||
import com.mojang.blaze3d.platform.GlStateManager.SrcFactor
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem
|
|
||||||
import me.shedaniel.math.Rectangle
|
import me.shedaniel.math.Rectangle
|
||||||
import me.shedaniel.rei.api.client.entry.renderer.BatchedEntryRenderer
|
|
||||||
import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer
|
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.Tooltip
|
||||||
import me.shedaniel.rei.api.client.gui.widgets.TooltipContext
|
import me.shedaniel.rei.api.client.gui.widgets.TooltipContext
|
||||||
@@ -21,23 +17,17 @@ import me.shedaniel.rei.api.common.entry.EntryStack
|
|||||||
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback
|
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback
|
||||||
import net.minecraft.client.MinecraftClient
|
import net.minecraft.client.MinecraftClient
|
||||||
import net.minecraft.client.gui.DrawContext
|
import net.minecraft.client.gui.DrawContext
|
||||||
import net.minecraft.client.render.DiffuseLighting
|
|
||||||
import net.minecraft.client.render.LightmapTextureManager
|
|
||||||
import net.minecraft.client.render.OverlayTexture
|
|
||||||
import net.minecraft.client.render.VertexConsumerProvider
|
|
||||||
import net.minecraft.client.render.model.BakedModel
|
|
||||||
import net.minecraft.client.texture.SpriteAtlasTexture
|
|
||||||
import net.minecraft.item.ModelTransformationMode
|
|
||||||
import net.minecraft.item.tooltip.TooltipType
|
import net.minecraft.item.tooltip.TooltipType
|
||||||
import moe.nea.firmament.compat.rei.FirmamentReiPlugin.Companion.asItemEntry
|
import moe.nea.firmament.compat.rei.FirmamentReiPlugin.Companion.asItemEntry
|
||||||
import moe.nea.firmament.events.ItemTooltipEvent
|
import moe.nea.firmament.events.ItemTooltipEvent
|
||||||
import moe.nea.firmament.repo.SBItemStack
|
import moe.nea.firmament.repo.SBItemStack
|
||||||
import moe.nea.firmament.util.ErrorUtil
|
import moe.nea.firmament.util.ErrorUtil
|
||||||
import moe.nea.firmament.util.MC
|
|
||||||
import moe.nea.firmament.util.mc.displayNameAccordingToNbt
|
import moe.nea.firmament.util.mc.displayNameAccordingToNbt
|
||||||
import moe.nea.firmament.util.mc.loreAccordingToNbt
|
import moe.nea.firmament.util.mc.loreAccordingToNbt
|
||||||
|
|
||||||
object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<SBItemStack, BakedModel> {
|
// TODO: make this re implement BatchedEntryRenderer, if possible (likely not, due to no-alloc rendering)
|
||||||
|
// Also it is probably not even that much faster now, with render layers.
|
||||||
|
object NEUItemEntryRenderer : EntryRenderer<SBItemStack> {
|
||||||
override fun render(
|
override fun render(
|
||||||
entry: EntryStack<SBItemStack>,
|
entry: EntryStack<SBItemStack>,
|
||||||
context: DrawContext,
|
context: DrawContext,
|
||||||
@@ -46,7 +36,14 @@ object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<S
|
|||||||
mouseY: Int,
|
mouseY: Int,
|
||||||
delta: Float
|
delta: Float
|
||||||
) {
|
) {
|
||||||
entry.asItemEntry().render(context, bounds, mouseX, mouseY, delta)
|
context.matrices.push()
|
||||||
|
context.matrices.translate(bounds.centerX.toFloat(), bounds.centerY.toFloat(), 0F)
|
||||||
|
context.matrices.scale(bounds.width.toFloat() / 16F, bounds.height.toFloat() / 16F, 1f)
|
||||||
|
context.drawItemWithoutEntity(
|
||||||
|
entry.asItemEntry().value,
|
||||||
|
-8, -8,
|
||||||
|
)
|
||||||
|
context.matrices.pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
val minecraft = MinecraftClient.getInstance()
|
val minecraft = MinecraftClient.getInstance()
|
||||||
@@ -85,88 +82,5 @@ object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<S
|
|||||||
return Tooltip.create(lore)
|
return Tooltip.create(lore)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getExtraData(entry: EntryStack<SBItemStack>): BakedModel {
|
|
||||||
return MC.itemRenderer.getModel(entry.asItemEntry().value,
|
|
||||||
MC.world,
|
|
||||||
MC.player, 0)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getBatchIdentifier(entry: EntryStack<SBItemStack>, bounds: Rectangle?, extraData: BakedModel): Int {
|
|
||||||
return 1738923 + if (extraData.isSideLit) 1 else 0
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override fun startBatch(entryStack: EntryStack<SBItemStack>, e: BakedModel, drawContext: DrawContext, v: Float) {
|
|
||||||
MC.textureManager.getTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE)
|
|
||||||
.setFilter(false, false)
|
|
||||||
RenderSystem.setShaderTexture(0, SpriteAtlasTexture.BLOCK_ATLAS_TEXTURE)
|
|
||||||
RenderSystem.enableBlend()
|
|
||||||
RenderSystem.blendFunc(SrcFactor.SRC_ALPHA, DstFactor.ONE_MINUS_SRC_ALPHA)
|
|
||||||
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f)
|
|
||||||
if (!e.isSideLit) {
|
|
||||||
DiffuseLighting.disableGuiDepthLighting()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun renderBase(
|
|
||||||
entryStack: EntryStack<SBItemStack>,
|
|
||||||
model: BakedModel,
|
|
||||||
drawContext: DrawContext,
|
|
||||||
immediate: VertexConsumerProvider.Immediate,
|
|
||||||
bounds: Rectangle,
|
|
||||||
i: Int,
|
|
||||||
i1: Int,
|
|
||||||
v: Float
|
|
||||||
) {
|
|
||||||
if (entryStack.isEmpty) return
|
|
||||||
drawContext.matrices.push()
|
|
||||||
drawContext.matrices.translate(bounds.centerX.toDouble(), bounds.centerY.toDouble(), 0.0)
|
|
||||||
// TODO: check the scaling here again
|
|
||||||
drawContext.matrices.scale(
|
|
||||||
bounds.width.toFloat(),
|
|
||||||
(bounds.height + bounds.height) / -2F,
|
|
||||||
(bounds.width + bounds.height) / 2f)
|
|
||||||
MC.itemRenderer.renderItem(
|
|
||||||
entryStack.value.asImmutableItemStack(),
|
|
||||||
ModelTransformationMode.GUI,
|
|
||||||
false, drawContext.matrices,
|
|
||||||
immediate, LightmapTextureManager.MAX_LIGHT_COORDINATE,
|
|
||||||
OverlayTexture.DEFAULT_UV,
|
|
||||||
model
|
|
||||||
)
|
|
||||||
drawContext.matrices.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun afterBase(entryStack: EntryStack<SBItemStack>?, e: BakedModel, drawContext: DrawContext?, v: Float) {
|
|
||||||
RenderSystem.enableDepthTest()
|
|
||||||
if (!e.isSideLit)
|
|
||||||
DiffuseLighting.enableGuiDepthLighting()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun renderOverlay(
|
|
||||||
entryStack: EntryStack<SBItemStack>,
|
|
||||||
e: BakedModel,
|
|
||||||
drawContext: DrawContext,
|
|
||||||
immediate: VertexConsumerProvider.Immediate,
|
|
||||||
bounds: Rectangle,
|
|
||||||
i: Int,
|
|
||||||
i1: Int,
|
|
||||||
v: Float
|
|
||||||
) {
|
|
||||||
if (entryStack.isEmpty) return
|
|
||||||
val modelViewStack = RenderSystem.getModelViewStack()
|
|
||||||
modelViewStack.pushMatrix()
|
|
||||||
modelViewStack.mul(drawContext.matrices.peek().positionMatrix)
|
|
||||||
modelViewStack.translate(bounds.x.toFloat(), bounds.y.toFloat(), 0F)
|
|
||||||
modelViewStack.scale(bounds.width / 16.0f,
|
|
||||||
(bounds.width + bounds.height) / 2.0f / 16.0f,
|
|
||||||
1.0f) // TODO: weird scale again
|
|
||||||
drawContext.drawStackOverlay(MC.font, entryStack.value.asImmutableItemStack(), 0, 0, null)
|
|
||||||
modelViewStack.popMatrix()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun endBatch(entryStack: EntryStack<SBItemStack>?, e: BakedModel?, drawContext: DrawContext?, v: Float) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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.EntryDefinition
|
||||||
import me.shedaniel.rei.api.common.entry.type.EntryType
|
import me.shedaniel.rei.api.common.entry.type.EntryType
|
||||||
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
|
import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes
|
||||||
|
import net.minecraft.item.ItemConvertible
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.registry.tag.TagKey
|
import net.minecraft.registry.tag.TagKey
|
||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
@@ -82,6 +83,8 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> {
|
|||||||
fun getEntry(ingredient: NEUIngredient): EntryStack<SBItemStack> =
|
fun getEntry(ingredient: NEUIngredient): EntryStack<SBItemStack> =
|
||||||
getEntry(SkyblockId(ingredient.itemId), count = ingredient.amount.toInt())
|
getEntry(SkyblockId(ingredient.itemId), count = ingredient.amount.toInt())
|
||||||
|
|
||||||
|
fun getPassthrough(item: ItemConvertible) = getEntry(SBItemStack.passthrough(ItemStack(item.asItem())))
|
||||||
|
|
||||||
fun getEntry(stack: ItemStack): EntryStack<SBItemStack> =
|
fun getEntry(stack: ItemStack): EntryStack<SBItemStack> =
|
||||||
getEntry(
|
getEntry(
|
||||||
SBItemStack(
|
SBItemStack(
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import net.minecraft.block.Blocks
|
|||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import moe.nea.firmament.Firmament
|
import moe.nea.firmament.Firmament
|
||||||
import moe.nea.firmament.compat.rei.SBItemEntryDefinition
|
import moe.nea.firmament.compat.rei.SBItemEntryDefinition
|
||||||
|
import moe.nea.firmament.repo.SBItemStack
|
||||||
|
|
||||||
class SBCraftingRecipe(override val neuRecipe: NEUCraftingRecipe) : SBRecipe() {
|
class SBCraftingRecipe(override val neuRecipe: NEUCraftingRecipe) : SBRecipe() {
|
||||||
override fun getCategoryIdentifier(): CategoryIdentifier<*> = Category.catIdentifier
|
override fun getCategoryIdentifier(): CategoryIdentifier<*> = Category.catIdentifier
|
||||||
@@ -26,7 +27,7 @@ class SBCraftingRecipe(override val neuRecipe: NEUCraftingRecipe) : SBRecipe() {
|
|||||||
|
|
||||||
override fun getTitle(): Text = Text.literal("SkyBlock Crafting")
|
override fun getTitle(): Text = Text.literal("SkyBlock Crafting")
|
||||||
|
|
||||||
override fun getIcon(): Renderer = EntryStacks.of(Blocks.CRAFTING_TABLE)
|
override fun getIcon(): Renderer = SBItemEntryDefinition.getPassthrough(Blocks.CRAFTING_TABLE)
|
||||||
override fun setupDisplay(display: SBCraftingRecipe, bounds: Rectangle): List<Widget> {
|
override fun setupDisplay(display: SBCraftingRecipe, bounds: Rectangle): List<Widget> {
|
||||||
val point = Point(bounds.centerX - 58, bounds.centerY - 27)
|
val point = Point(bounds.centerX - 58, bounds.centerY - 27)
|
||||||
return buildList {
|
return buildList {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class SBForgeRecipe(override val neuRecipe: NEUForgeRecipe) : SBRecipe() {
|
|||||||
return 104
|
return 104
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIcon(): Renderer = EntryStacks.of(Blocks.ANVIL)
|
override fun getIcon(): Renderer = SBItemEntryDefinition.getPassthrough(Blocks.ANVIL)
|
||||||
override fun setupDisplay(display: SBForgeRecipe, bounds: Rectangle): List<Widget> {
|
override fun setupDisplay(display: SBForgeRecipe, bounds: Rectangle): List<Widget> {
|
||||||
return buildList {
|
return buildList {
|
||||||
add(Widgets.createRecipeBase(bounds))
|
add(Widgets.createRecipeBase(bounds))
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class SBKatRecipe(override val neuRecipe: NEUKatUpgradeRecipe) : SBRecipe() {
|
|||||||
return 100
|
return 100
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIcon(): Renderer = EntryStacks.of(Items.BONE)
|
override fun getIcon(): Renderer = SBItemEntryDefinition.getPassthrough(Items.BONE)
|
||||||
override fun setupDisplay(display: SBKatRecipe, bounds: Rectangle): List<Widget> {
|
override fun setupDisplay(display: SBKatRecipe, bounds: Rectangle): List<Widget> {
|
||||||
return buildList {
|
return buildList {
|
||||||
val arrowWidth = 24
|
val arrowWidth = 24
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class SBMobDropRecipe(override val neuRecipe: NEUMobDropRecipe) : SBRecipe() {
|
|||||||
return 100
|
return 100
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIcon(): Renderer = EntryStacks.of(Items.DIAMOND_SWORD)
|
override fun getIcon(): Renderer = SBItemEntryDefinition.getPassthrough(Items.DIAMOND_SWORD)
|
||||||
override fun setupDisplay(display: SBMobDropRecipe, bounds: Rectangle): List<Widget> {
|
override fun setupDisplay(display: SBMobDropRecipe, bounds: Rectangle): List<Widget> {
|
||||||
return buildList {
|
return buildList {
|
||||||
add(Widgets.createRecipeBase(bounds))
|
add(Widgets.createRecipeBase(bounds))
|
||||||
|
|||||||
@@ -70,6 +70,12 @@ object ItemCache : IReloadable {
|
|||||||
|
|
||||||
val ItemStack.isBroken
|
val ItemStack.isBroken
|
||||||
get() = get(FirmamentDataComponentTypes.IS_BROKEN) ?: false
|
get() = get(FirmamentDataComponentTypes.IS_BROKEN) ?: false
|
||||||
|
|
||||||
|
fun ItemStack.withFallback(fallback: ItemStack?): ItemStack {
|
||||||
|
if (isBroken && fallback != null) return fallback
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
fun brokenItemStack(neuItem: NEUItem?, idHint: SkyblockId? = null): ItemStack {
|
fun brokenItemStack(neuItem: NEUItem?, idHint: SkyblockId? = null): ItemStack {
|
||||||
return ItemStack(Items.PAINTING).apply {
|
return ItemStack(Items.PAINTING).apply {
|
||||||
setCustomName(Text.literal(neuItem?.displayName ?: idHint?.neuItem ?: "null"))
|
setCustomName(Text.literal(neuItem?.displayName ?: idHint?.neuItem ?: "null"))
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.minecraft.network.codec.PacketCodecs
|
|||||||
import net.minecraft.text.Text
|
import net.minecraft.text.Text
|
||||||
import net.minecraft.util.Formatting
|
import net.minecraft.util.Formatting
|
||||||
import moe.nea.firmament.repo.ItemCache.asItemStack
|
import moe.nea.firmament.repo.ItemCache.asItemStack
|
||||||
|
import moe.nea.firmament.repo.ItemCache.withFallback
|
||||||
import moe.nea.firmament.util.FirmFormatters
|
import moe.nea.firmament.util.FirmFormatters
|
||||||
import moe.nea.firmament.util.LegacyFormattingCode
|
import moe.nea.firmament.util.LegacyFormattingCode
|
||||||
import moe.nea.firmament.util.SkyblockId
|
import moe.nea.firmament.util.SkyblockId
|
||||||
@@ -30,6 +31,7 @@ data class SBItemStack constructor(
|
|||||||
val extraLore: List<Text> = emptyList(),
|
val extraLore: List<Text> = emptyList(),
|
||||||
// TODO: grab this star data from nbt if possible
|
// TODO: grab this star data from nbt if possible
|
||||||
val stars: Int = 0,
|
val stars: Int = 0,
|
||||||
|
val fallback: ItemStack? = null,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun getStackSize() = stackSize
|
fun getStackSize() = stackSize
|
||||||
@@ -77,6 +79,10 @@ data class SBItemStack constructor(
|
|||||||
}
|
}
|
||||||
return SBItemStack(neuIngredient.skyblockId, neuIngredient.amount.toInt())
|
return SBItemStack(neuIngredient.skyblockId, neuIngredient.amount.toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun passthrough(itemStack: ItemStack): SBItemStack {
|
||||||
|
return SBItemStack(SkyblockId.NULL, null, itemStack.count, null, fallback = itemStack)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(skyblockId: SkyblockId, petData: PetData) : this(
|
constructor(skyblockId: SkyblockId, petData: PetData) : this(
|
||||||
@@ -139,6 +145,7 @@ data class SBItemStack constructor(
|
|||||||
val replacementData = mutableMapOf<String, String>()
|
val replacementData = mutableMapOf<String, String>()
|
||||||
injectReplacementDataForPets(replacementData)
|
injectReplacementDataForPets(replacementData)
|
||||||
return@run neuItem.asItemStack(idHint = skyblockId, replacementData)
|
return@run neuItem.asItemStack(idHint = skyblockId, replacementData)
|
||||||
|
.withFallback(fallback)
|
||||||
.copyWithCount(stackSize)
|
.copyWithCount(stackSize)
|
||||||
.also { it.appendLore(extraLore) }
|
.also { it.appendLore(extraLore) }
|
||||||
.also { enhanceStatsByStars(it, stars) }
|
.also { enhanceStatsByStars(it, stars) }
|
||||||
|
|||||||
Reference in New Issue
Block a user