Update to 1.20

- Remove some devenv mods that are not updated yet
 - Replace lib39 with fletchingtable for automixins
 - Use non kotlin entrypoints
 - Make use of DrawContext in a bunch of places
This commit is contained in:
nea
2023-06-08 00:11:46 +02:00
parent b65382a7b7
commit f98a1f5d53
14 changed files with 106 additions and 87 deletions

View File

@@ -10,6 +10,7 @@ plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
id("moe.nea.licenseextractificator")
id("io.github.juuxel.loom-quiltflower") version "1.10.0"
id("io.shcm.shsupercm.fabric.fletchingtable") version "1.5"
}
java {
@@ -88,8 +89,6 @@ dependencies {
modImplementation(libs.fabric.kotlin)
modImplementation(libs.modmenu)
modImplementation(libs.libgui)
modImplementation(libs.lib39.core)
include(libs.lib39.core)
include(libs.libgui)
modApi(libs.fabric.api)
modApi(libs.architectury)
@@ -197,3 +196,5 @@ tasks.create("printAllLicenses", LicenseDiscoveryTask::class.java, licensing).ap
}
licensing.addExtraLicenseMatchers()
fletchingTable.defaultMixinEnvironment.set("client")

View File

@@ -1,22 +1,21 @@
[versions]
minecraft = "1.19.4"
minecraft = "1.20"
fabric_loader = "0.14.21"
fabric_api = "0.83.0+1.19.4"
fabric_api = "0.83.0+1.20"
fabric_kotlin = "1.9.4+kotlin.1.8.21"
yarn = "1.19.4+build.2"
libgui = "7.1.0+1.19.4"
rei = "11.0.597"
yarn = "1.20+build.1"
libgui = "8.0.0-beta.1+1.20-rc1" # TODO: Update
rei = "12.0.613" # TODO: Update
devauth = "1.0.0"
modmenu = "6.2.1"
modmenu = "7.0.0"
ktor = "2.3.0"
dbus_java = "4.2.1"
architectury = "8.1.79"
architectury = "9.0.5" # TODO: Update
neurepoparser = "1.3.1"
qolify = "1.2.2-1.19.4"
citresewn = "1.1.3+1.19.4"
lib39 = "1.4.2"
qolify = "1.2.2-1.19.4" # TODO: Update
citresewn = "1.1.3+1.19.4" # TODO: Update
hotswap_agent = "1.4.2-SNAPSHOT"
ncr = "Fabric-1.19.4-v2.1.1"
ncr = "Fabric-1.19.4-v2.1.1" # TODO: Update
[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
@@ -29,7 +28,6 @@ repoparser = { module = "moe.nea:neurepoparser", version.ref = "neurepoparser" }
dbus_java_core = { module = "com.github.hypfvieh:dbus-java-core", version.ref = "dbus_java" }
dbus_java_unixsocket = { module = "com.github.hypfvieh:dbus-java-transport-native-unixsocket", version.ref = "dbus_java" }
libgui = { module = "io.github.cottonmc:LibGui", version.ref = "libgui" }
lib39_core = { module = "com.unascribed:lib39-core", version.ref = "lib39" }
# Runtime:
hotswap = { module = "virtual.github.hotswapagent:hotswap-agent", version.ref = "hotswap_agent" }
@@ -44,7 +42,12 @@ ncr = { module = "maven.modrinth:no-chat-reports", version.ref = "ncr" }
[bundles]
dbus = ["dbus_java_core", "dbus_java_unixsocket"]
runtime_required = ["architectury_fabric", "rei_fabric"]
runtime_optional = ["devauth", "qolify", "citresewn", "ncr"]
runtime_optional = [
"devauth",
# Add back once updated:
# "qolify",
# "citresewn",
# "ncr",
]

View File

@@ -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) {
}
}

View File

@@ -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);
}
}

View File

@@ -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,

View File

@@ -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()

View File

@@ -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

View File

@@ -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,

View File

@@ -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)
}
}

View File

@@ -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) {

View File

@@ -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,

View File

@@ -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? {

View File

@@ -21,16 +21,10 @@
"environment": "client",
"entrypoints": {
"main": [
{
"adapter": "kotlin",
"value": "moe.nea.firmament.Firmament"
}
"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"

View File

@@ -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
}