diff options
Diffstat (limited to 'src')
12 files changed, 86 insertions, 71 deletions
diff --git a/src/main/java/moe/nea/firmament/init/MixinPlugin.java b/src/main/java/moe/nea/firmament/init/MixinPlugin.java index 79a1789..663c9d9 100644 --- a/src/main/java/moe/nea/firmament/init/MixinPlugin.java +++ b/src/main/java/moe/nea/firmament/init/MixinPlugin.java @@ -18,25 +18,49 @@ package moe.nea.firmament.init; -import com.unascribed.lib39.core.api.AutoMixin; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; import java.util.List; +import java.util.Set; -// TODO: replace AutoMixin with KSP plugin? -public class MixinPlugin extends AutoMixin { +public class MixinPlugin implements IMixinConfigPlugin { + + @Override + public void onLoad(String mixinPackage) { + } + + @Override + public String getRefMapperConfig() { + return null; + } @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { if (!Boolean.getBoolean("firmament.debug") && mixinClassName.contains("devenv.")) { return false; } - return super.shouldApplyMixin(targetClassName, mixinClassName); + return true; + } + + @Override + public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { + } @Override public List<String> getMixins() { - var autoDiscoveredMixins = super.getMixins(); - autoDiscoveredMixins.removeIf(it -> !shouldApplyMixin(null, it)); - return autoDiscoveredMixins; + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + } } diff --git a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java index 23670b7..ac09569 100644 --- a/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java +++ b/src/main/java/moe/nea/firmament/mixins/MixinHandledScreen.java @@ -21,6 +21,7 @@ package moe.nea.firmament.mixins; import moe.nea.firmament.events.HandledScreenKeyPressedEvent; import moe.nea.firmament.events.IsSlotProtectedEvent; import moe.nea.firmament.events.SlotRenderEvents; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.screen.slot.Slot; @@ -50,19 +51,15 @@ public class MixinHandledScreen { } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) - public void onAfterDrawSlot( - MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci, - int i, int j, int k, Slot slot) { - SlotRenderEvents.After event = new SlotRenderEvents.After(matrices, slot, mouseX, mouseY, delta); + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/screen/slot/Slot;)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD) + public void onAfterDrawSlot(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci, int i, int j, int k, Slot slot) { + SlotRenderEvents.After event = new SlotRenderEvents.After(context, slot, mouseX, mouseY, delta); SlotRenderEvents.After.Companion.publish(event); } - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/screen/slot/Slot;)V", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) - public void onBeforeDrawSlot( - MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci, - int i, int j, int k, Slot slot) { - SlotRenderEvents.Before event = new SlotRenderEvents.Before(matrices, slot, mouseX, mouseY, delta); + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/screen/slot/Slot;)V", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) + public void onBeforeDrawSlot(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci, int i, int j, int k, Slot slot) { + SlotRenderEvents.Before event = new SlotRenderEvents.Before(context, slot, mouseX, mouseY, delta); SlotRenderEvents.Before.Companion.publish(event); } } diff --git a/src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java b/src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java index 3d9d408..2aebd8e 100644 --- a/src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java +++ b/src/main/java/moe/nea/firmament/mixins/MixinWorldRenderer.java @@ -32,7 +32,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(WorldRenderer.class) public class MixinWorldRenderer { - @Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;applyModelViewMatrix()V", shift = At.Shift.AFTER)) + @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.BEFORE)) public void onWorldRenderLast(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) { var event = new WorldRenderLastEvent( matrices, tickDelta, renderBlockOutline, diff --git a/src/main/kotlin/moe/nea/firmament/Firmament.kt b/src/main/kotlin/moe/nea/firmament/Firmament.kt index 6132d3b..f130742 100644 --- a/src/main/kotlin/moe/nea/firmament/Firmament.kt +++ b/src/main/kotlin/moe/nea/firmament/Firmament.kt @@ -19,18 +19,15 @@ package moe.nea.firmament import com.mojang.brigadier.CommandDispatcher -import io.ktor.client.HttpClient -import io.ktor.client.plugins.UserAgent -import io.ktor.client.plugins.cache.HttpCache -import io.ktor.client.plugins.compression.ContentEncoding -import io.ktor.client.plugins.contentnegotiation.ContentNegotiation -import io.ktor.client.plugins.logging.LogLevel -import io.ktor.client.plugins.logging.Logging -import io.ktor.serialization.kotlinx.json.json +import io.ktor.client.* +import io.ktor.client.plugins.* +import io.ktor.client.plugins.cache.* +import io.ktor.client.plugins.compression.* +import io.ktor.client.plugins.contentnegotiation.* +import io.ktor.client.plugins.logging.* +import io.ktor.serialization.kotlinx.json.* import java.nio.file.Files import java.nio.file.Path -import net.fabricmc.api.ClientModInitializer -import net.fabricmc.api.ModInitializer import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents @@ -58,7 +55,7 @@ import moe.nea.firmament.repo.RepoManager import moe.nea.firmament.util.SBData import moe.nea.firmament.util.data.IDataHolder -object Firmament : ModInitializer, ClientModInitializer { +object Firmament { const val MOD_ID = "firmament" val DEBUG = System.getProperty("firmament.debug") == "true" @@ -110,10 +107,12 @@ object Firmament : ModInitializer, ClientModInitializer { registerFirmamentCommand(dispatcher) } - override fun onInitialize() { + @JvmStatic + fun onInitialize() { } - override fun onInitializeClient() { + @JvmStatic + fun onClientInitialize() { dbusConnection.requestBusName("moe.nea.firmament") dbusConnection.exportObject(FirmamentDbusObject) IDataHolder.registerEvents() diff --git a/src/main/kotlin/moe/nea/firmament/events/SlotRenderEvents.kt b/src/main/kotlin/moe/nea/firmament/events/SlotRenderEvents.kt index 695d9c2..c4b0a3d 100644 --- a/src/main/kotlin/moe/nea/firmament/events/SlotRenderEvents.kt +++ b/src/main/kotlin/moe/nea/firmament/events/SlotRenderEvents.kt @@ -18,18 +18,18 @@ package moe.nea.firmament.events -import net.minecraft.client.util.math.MatrixStack +import net.minecraft.client.gui.DrawContext import net.minecraft.screen.slot.Slot interface SlotRenderEvents { - val matrices: MatrixStack + val context: DrawContext val slot: Slot val mouseX: Int val mouseY: Int val delta: Float data class Before( - override val matrices: MatrixStack, override val slot: Slot, + override val context: DrawContext, override val slot: Slot, override val mouseX: Int, override val mouseY: Int, override val delta: Float @@ -39,7 +39,7 @@ interface SlotRenderEvents { } data class After( - override val matrices: MatrixStack, override val slot: Slot, + override val context: DrawContext, override val slot: Slot, override val mouseX: Int, override val mouseY: Int, override val delta: Float diff --git a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt index 27761ce..eab0da0 100644 --- a/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt +++ b/src/main/kotlin/moe/nea/firmament/features/inventory/SlotLocking.kt @@ -20,7 +20,7 @@ package moe.nea.firmament.features.inventory import kotlinx.serialization.Serializable import kotlinx.serialization.serializer -import net.minecraft.client.gui.DrawableHelper +import net.minecraft.client.gui.DrawContext import net.minecraft.entity.player.PlayerInventory import moe.nea.firmament.events.HandledScreenKeyPressedEvent import moe.nea.firmament.events.IsSlotProtectedEvent @@ -72,8 +72,7 @@ object SlotLocking : FirmamentFeature { } SlotRenderEvents.Before.subscribe { if (it.slot.inventory is PlayerInventory && it.slot.index in (lockedSlots ?: setOf())) { - DrawableHelper.fill( - it.matrices, + it.context.fill( it.slot.x, it.slot.y, it.slot.x + 16, diff --git a/src/main/kotlin/moe/nea/firmament/gui/WBar.kt b/src/main/kotlin/moe/nea/firmament/gui/WBar.kt index 04c5e3d..ed812ec 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/WBar.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/WBar.kt @@ -5,6 +5,7 @@ import io.github.cottonmc.cotton.gui.client.ScreenDrawing import io.github.cottonmc.cotton.gui.widget.WWidget import io.github.cottonmc.cotton.gui.widget.data.Texture import me.shedaniel.math.Color +import net.minecraft.client.gui.DrawContext import net.minecraft.client.util.math.MatrixStack import moe.nea.firmament.Firmament @@ -27,7 +28,7 @@ open class WBar( } private fun drawSection( - matrices: MatrixStack, + context: DrawContext, texture: Texture, x: Int, y: Int, @@ -36,18 +37,18 @@ open class WBar( sectionEnd: Double ) { if (sectionEnd < progress && width == 4) { - ScreenDrawing.texturedRect(matrices, x, y, 4, 8, texture, fillColor.color) + ScreenDrawing.texturedRect(context, x, y, 4, 8, texture, fillColor.color) return } if (sectionStart > progress && width == 4) { - ScreenDrawing.texturedRect(matrices, x, y, 4, 8, texture, emptyColor.color) + ScreenDrawing.texturedRect(context, x, y, 4, 8, texture, emptyColor.color) return } val increasePerPixel = (sectionEnd - sectionStart / 4) var valueAtPixel = sectionStart for (i in (0 until width)) { ScreenDrawing.texturedRect( - matrices, x + i, y, 1, 8, + context, x + i, y, 1, 8, texture.image, texture.u1 + i / 64F, texture.v1, texture.u1 + (i + 1) / 64F, texture.v2, if (valueAtPixel < progress) fillColor.color else emptyColor.color ) @@ -55,11 +56,11 @@ open class WBar( } } - override fun paint(matrices: MatrixStack, x: Int, y: Int, mouseX: Int, mouseY: Int) { + override fun paint(context: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) { var i = 0 while (i < width - 4) { drawSection( - matrices, + context, if (i == 0) left else middle, x + i, y, (width - (i + 4)).coerceAtMost(4), @@ -67,7 +68,7 @@ open class WBar( ) i += 4 } - drawSection(matrices, right, x + width - 4, y, 4, (width - 4) * total / width, total) + drawSection(context, right, x + width - 4, y, 4, (width - 4) * total / width, total) RenderSystem.setShaderColor(1F, 1F, 1F, 1F) } } diff --git a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt index 4c669df..62889bd 100644 --- a/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt +++ b/src/main/kotlin/moe/nea/firmament/gui/profileviewer/PetsPage.kt @@ -9,8 +9,8 @@ import io.github.cottonmc.cotton.gui.widget.WWidget import io.github.cottonmc.cotton.gui.widget.data.Insets import io.github.cottonmc.cotton.gui.widget.icon.Icon import io.github.cottonmc.cotton.gui.widget.icon.ItemIcon +import net.minecraft.client.gui.DrawContext import net.minecraft.client.item.TooltipContext -import net.minecraft.client.util.math.MatrixStack import net.minecraft.item.Items import net.minecraft.text.Text import moe.nea.firmament.gui.WTightScrollPanel @@ -27,9 +27,9 @@ object PetsPage : ProfilePage { for ((i, pet) in profileViewer.member.pets.withIndex()) { val stack = SBItemStack(pet.itemId, PetData(pet.tier, pet.type.name, pet.exp)).asItemStack() it.add(object : WItem(stack) { - override fun paint(matrices: MatrixStack?, x: Int, y: Int, mouseX: Int, mouseY: Int) { - BackgroundPainter.SLOT.paintBackground(matrices, x, y, this) - super.paint(matrices, x, y, mouseX, mouseY) + override fun paint(context: DrawContext?, x: Int, y: Int, mouseX: Int, mouseY: Int) { + BackgroundPainter.SLOT.paintBackground(context, x, y, this) + super.paint(context, x, y, mouseX, mouseY) } override fun addTooltip(tooltip: TooltipBuilder) { diff --git a/src/main/kotlin/moe/nea/firmament/hud/RepoDownloadProgress.kt b/src/main/kotlin/moe/nea/firmament/hud/RepoDownloadProgress.kt index 69e0384..827835a 100644 --- a/src/main/kotlin/moe/nea/firmament/hud/RepoDownloadProgress.kt +++ b/src/main/kotlin/moe/nea/firmament/hud/RepoDownloadProgress.kt @@ -25,6 +25,7 @@ import io.github.cottonmc.cotton.gui.widget.data.Insets import net.minecraft.client.util.math.MatrixStack import kotlin.math.roundToInt import kotlin.math.sin +import net.minecraft.client.gui.DrawContext val Insets.vertical get() = bottom + top @@ -49,8 +50,8 @@ class ProgressBar( } - override fun paint(matrices: MatrixStack, x: Int, y: Int, mouseX: Int, mouseY: Int) { - ScreenDrawing.coloredRect(matrices, x, y, width, height, 0xFF808080.toInt()) + override fun paint(context: DrawContext, x: Int, y: Int, mouseX: Int, mouseY: Int) { + ScreenDrawing.coloredRect(context, x, y, width, height, 0xFF808080.toInt()) val (l, prog) = synchronized(this) { label to (progress to total) } @@ -58,7 +59,7 @@ class ProgressBar( if (t == null) { ScreenDrawing.coloredRect( - matrices, + context, (x + (1 + sin(System.currentTimeMillis().toDouble() / 1000)) * width * 3 / 4 / 2).roundToInt(), y, width / 4, @@ -66,10 +67,10 @@ class ProgressBar( 0xFF00FF00.toInt() ) } else { - ScreenDrawing.coloredRect(matrices, x, y, width * p / t, height, 0xFF00FF00.toInt()) + ScreenDrawing.coloredRect(context, x, y, width * p / t, height, 0xFF00FF00.toInt()) } ScreenDrawing.drawString( - matrices, + context, if (t != null) "$l ($p/$t)" else l, HorizontalAlignment.CENTER, x + insets.left, diff --git a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt index 32186be..deaaeb9 100644 --- a/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt +++ b/src/main/kotlin/moe/nea/firmament/rei/NEUItemEntryRenderer.kt @@ -23,22 +23,22 @@ 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 net.minecraft.client.gui.DrawContext import moe.nea.firmament.rei.FirmamentReiPlugin.Companion.asItemEntry object NEUItemEntryRenderer : EntryRenderer<SBItemStack> { override fun render( entry: EntryStack<SBItemStack>, - matrices: MatrixStack, + context: DrawContext, 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() + context.matrices.push() + context.matrices.translate(0F, 0F, 100F) + entry.asItemEntry().render(context, bounds, mouseX, mouseY, delta) + context.matrices.pop() } override fun getTooltip(entry: EntryStack<SBItemStack>, tooltipContext: TooltipContext): Tooltip? { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 063bda7..c227e49 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,17 +20,11 @@ "icon": "assets/firmament/icon.png", "environment": "client", "entrypoints": { - "main": [ - { - "adapter": "kotlin", - "value": "moe.nea.firmament.Firmament" - } - ], + "main": [ + "moe.nea.firmament.Firmament::onInitialize" + ], "client": [ - { - "adapter": "kotlin", - "value": "moe.nea.firmament.Firmament" - } + "moe.nea.firmament.Firmament::onClientInitialize" ], "rei_client": [ "moe.nea.firmament.rei.FirmamentReiPlugin" diff --git a/src/main/resources/firmament.mixins.json b/src/main/resources/firmament.mixins.json index 43f3601..599c8ea 100644 --- a/src/main/resources/firmament.mixins.json +++ b/src/main/resources/firmament.mixins.json @@ -2,7 +2,7 @@ "required": true, "plugin": "moe.nea.firmament.init.MixinPlugin", "package": "moe.nea.firmament.mixins", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_17", "injectors": { "defaultRequire": 1 } |