diff options
Diffstat (limited to 'src/compat')
9 files changed, 78 insertions, 125 deletions
diff --git a/src/compat/moulconfig/java/MCConfigEditorIntegration.kt b/src/compat/moulconfig/java/MCConfigEditorIntegration.kt index 20a79a8..dec2559 100644 --- a/src/compat/moulconfig/java/MCConfigEditorIntegration.kt +++ b/src/compat/moulconfig/java/MCConfigEditorIntegration.kt @@ -20,6 +20,7 @@ import io.github.notenoughupdates.moulconfig.gui.editors.ComponentEditor import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorAccordion import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorBoolean import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorButton +import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorDropdown import io.github.notenoughupdates.moulconfig.gui.editors.GuiOptionEditorText import io.github.notenoughupdates.moulconfig.observer.GetSetter import io.github.notenoughupdates.moulconfig.processor.ProcessedCategory @@ -31,9 +32,11 @@ import kotlin.time.Duration.Companion.seconds import kotlin.time.DurationUnit import net.minecraft.client.gui.screen.Screen import net.minecraft.util.Identifier +import net.minecraft.util.StringIdentifiable import net.minecraft.util.Util import moe.nea.firmament.Firmament import moe.nea.firmament.gui.config.BooleanHandler +import moe.nea.firmament.gui.config.ChoiceHandler import moe.nea.firmament.gui.config.ClickHandler import moe.nea.firmament.gui.config.DurationHandler import moe.nea.firmament.gui.config.FirmamentConfigScreenProvider @@ -115,7 +118,33 @@ class MCConfigEditorIntegration : FirmamentConfigScreenProvider { } } + fun <T> helpRegisterChoice() where T : Enum<T>, T : StringIdentifiable { + register(ChoiceHandler::class.java as Class<ChoiceHandler<T>>) { handler, option, categoryAccordionId, configObject -> + object : ProcessedEditableOptionFirm<T>(option, categoryAccordionId, configObject) { + override fun createEditor(): GuiOptionEditor { + return GuiOptionEditorDropdown( + this, + handler.universe.map { handler.renderer.getName(option, it).string }.toTypedArray() + ) + } + + override fun toT(any: Any?): T? { + return handler.universe[any as Int] + } + + override fun getType(): Type { + return Int::class.java + } + + override fun fromT(t: T): Any { + return t.ordinal + } + } + } + } + init { + helpRegisterChoice<Nothing>() register(BooleanHandler::class.java) { handler, option, categoryAccordionId, configObject -> object : ProcessedEditableOptionFirm<Boolean>(option, categoryAccordionId, configObject) { override fun createEditor(): GuiOptionEditor { diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt index 336c103..a7b4c99 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/NEUItemEntryRenderer.kt @@ -9,11 +9,7 @@ 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.rei.api.client.entry.renderer.BatchedEntryRenderer 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 @@ -21,23 +17,17 @@ import me.shedaniel.rei.api.common.entry.EntryStack import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback import net.minecraft.client.MinecraftClient 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 moe.nea.firmament.compat.rei.FirmamentReiPlugin.Companion.asItemEntry import moe.nea.firmament.events.ItemTooltipEvent import moe.nea.firmament.repo.SBItemStack 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.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( entry: EntryStack<SBItemStack>, context: DrawContext, @@ -46,7 +36,14 @@ object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<S mouseY: Int, 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() @@ -85,88 +82,5 @@ object NEUItemEntryRenderer : EntryRenderer<SBItemStack>, BatchedEntryRenderer<S 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) { - } } diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt index a242c1b..9638281 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/SBItemEntryDefinition.kt @@ -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.EntryType import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes +import net.minecraft.item.ItemConvertible import net.minecraft.item.ItemStack import net.minecraft.registry.tag.TagKey import net.minecraft.text.Text @@ -82,6 +83,8 @@ object SBItemEntryDefinition : EntryDefinition<SBItemStack> { fun getEntry(ingredient: NEUIngredient): EntryStack<SBItemStack> = getEntry(SkyblockId(ingredient.itemId), count = ingredient.amount.toInt()) + fun getPassthrough(item: ItemConvertible) = getEntry(SBItemStack.passthrough(ItemStack(item.asItem()))) + fun getEntry(stack: ItemStack): EntryStack<SBItemStack> = getEntry( SBItemStack( diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBCraftingRecipe.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBCraftingRecipe.kt index fd04abc..8db3d75 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBCraftingRecipe.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBCraftingRecipe.kt @@ -16,6 +16,7 @@ import net.minecraft.block.Blocks import net.minecraft.text.Text import moe.nea.firmament.Firmament import moe.nea.firmament.compat.rei.SBItemEntryDefinition +import moe.nea.firmament.repo.SBItemStack class SBCraftingRecipe(override val neuRecipe: NEUCraftingRecipe) : SBRecipe() { 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 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> { val point = Point(bounds.centerX - 58, bounds.centerY - 27) return buildList { @@ -39,7 +40,7 @@ class SBCraftingRecipe(override val neuRecipe: NEUCraftingRecipe) : SBRecipe() { add(slot) val item = display.neuRecipe.inputs[i + j * 3] if (item == NEUIngredient.SENTINEL_EMPTY) continue - slot.entry(SBItemEntryDefinition.getEntry(item)) // TODO: make use of stackable item entries + slot.entry(SBItemEntryDefinition.getEntry(item)) } } add( diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBForgeRecipe.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBForgeRecipe.kt index 96af3fd..92b2f3f 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBForgeRecipe.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBForgeRecipe.kt @@ -30,7 +30,7 @@ class SBForgeRecipe(override val neuRecipe: NEUForgeRecipe) : SBRecipe() { 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> { return buildList { add(Widgets.createRecipeBase(bounds)) diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt index bafbdcc..cce1465 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBKatRecipe.kt @@ -43,7 +43,7 @@ class SBKatRecipe(override val neuRecipe: NEUKatUpgradeRecipe) : SBRecipe() { 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> { return buildList { val arrowWidth = 24 diff --git a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBMobDropRecipe.kt b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBMobDropRecipe.kt index b05c3c7..b595c23 100644 --- a/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBMobDropRecipe.kt +++ b/src/compat/rei/java/moe/nea/firmament/compat/rei/recipes/SBMobDropRecipe.kt @@ -29,7 +29,7 @@ class SBMobDropRecipe(override val neuRecipe: NEUMobDropRecipe) : SBRecipe() { 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> { return buildList { add(Widgets.createRecipeBase(bounds)) diff --git a/src/compat/rei/java/moe/nea/firmament/mixins/compat/HideREIRecipeWarning.java b/src/compat/rei/java/moe/nea/firmament/mixins/compat/HideREIRecipeWarning.java new file mode 100644 index 0000000..14eeaf2 --- /dev/null +++ b/src/compat/rei/java/moe/nea/firmament/mixins/compat/HideREIRecipeWarning.java @@ -0,0 +1,20 @@ +package moe.nea.firmament.mixins.compat; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(targets = "me.shedaniel.rei.impl.client.gui.hints.ImportantWarningsWidget") +@Pseudo +public class HideREIRecipeWarning { + @Shadow + private boolean visible; + + @Inject(method = "<init>", at = @At("TAIL")) + private void onCreateImportantWidget(CallbackInfo ci) { + visible = false; + } +} diff --git a/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java b/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java index 723af59..c3e8950 100644 --- a/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java +++ b/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java @@ -1,14 +1,12 @@ package moe.nea.firmament.mixins.compat.wildfiregender; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.sugar.Local; import com.wildfire.render.GenderArmorLayer; import moe.nea.firmament.features.texturepack.CustomGlobalArmorOverrides; -import net.minecraft.item.ArmorItem; -import net.minecraft.item.ArmorMaterial; +import net.minecraft.component.type.EquippableComponent; +import net.minecraft.entity.EquipmentSlot; import net.minecraft.item.ItemStack; -import net.minecraft.registry.entry.RegistryEntry; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; @@ -16,22 +14,10 @@ import org.spongepowered.asm.mixin.injection.At; @Mixin(GenderArmorLayer.class) @Pseudo public class PatchArmorTexturesInGenderMod { - @WrapOperation(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/entity/LivingEntity;FFFFFF)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ArmorItem;getMaterial()Lnet/minecraft/registry/entry/RegistryEntry;")) - private RegistryEntry<ArmorMaterial> replaceArmorMaterial(ArmorItem instance, Operation<RegistryEntry<ArmorMaterial>> original, @Local ItemStack chestplate) { - var entry = original.call(instance); - var overrides = CustomGlobalArmorOverrides.overrideArmor(chestplate); - if (overrides == null) - return entry; - var material = entry.value(); - return RegistryEntry.of(new ArmorMaterial( - material.defense(), - material.enchantability(), - material.equipSound(), - material.repairIngredient(), - overrides, - material.toughness(), - material.knockbackResistance() - )); - } + @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/BipedEntityRenderState;FF)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;get(Lnet/minecraft/component/ComponentType;)Ljava/lang/Object;")) + private Object replaceArmorMaterial(Object original, @Local ItemStack chestplate) { + var overrides = CustomGlobalArmorOverrides.overrideArmor(chestplate, EquipmentSlot.CHEST); + return overrides.orElse((EquippableComponent) original); + } } |