diff options
| author | nea <romangraef@gmail.com> | 2022-09-28 12:45:56 +0200 |
|---|---|---|
| committer | nea <romangraef@gmail.com> | 2022-09-28 12:45:56 +0200 |
| commit | 4d73331a449f0b0647066f7dde0628730fe0e178 (patch) | |
| tree | 047f463e13d14ea6cf9c8b37602a756f6880f9a0 | |
| parent | ec66c82198fe2d61d699d553c1254f08b43fcc65 (diff) | |
| download | Firmament-4d73331a449f0b0647066f7dde0628730fe0e178.tar.gz Firmament-4d73331a449f0b0647066f7dde0628730fe0e178.tar.bz2 Firmament-4d73331a449f0b0647066f7dde0628730fe0e178.zip | |
Fairy souls
28 files changed, 835 insertions, 203 deletions
@@ -4,3 +4,11 @@ ### Building your own +Use Java 17. + +This depends on [neurepoparsing](https://git.nea.moe/nea/neurepoparsing/). Please clone that repository and make it available in your local maven repository using `./gradlew publishToMavenLocal`. This will be automated at a later stage. + + +Afterwards, running `./gradlew build` will create a mod jar in `build/libs` + + diff --git a/build.gradle.kts b/build.gradle.kts index d2b9494..31461f0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,8 +8,7 @@ plugins { id("dev.architectury.loom") version "0.12.0.+" id("com.github.johnrengelman.shadow") version "7.1.2" id("moe.nea.licenseextractificator") version "fffc76c" - id("com.github.eutro.hierarchical-lang") version "1.1.3" - id("io.github.juuxel.loom-quiltflower") version "1.7.2" + id("io.github.juuxel.loom-quiltflower") version "1.7.3" } loom { @@ -24,6 +23,12 @@ loom { property("notenoughupdates.debug", "true") } } + runs { + named("client") { + vmArg("-XX:+AllowEnhancedClassRedefinition") + vmArg("-XX:HotswapAgent=fatjar") + } + } } repositories { @@ -59,12 +64,16 @@ dependencies { modImplementation("net.fabricmc:fabric-loader:${project.property("fabric_loader_version")}") modApi("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_api_version")}") modImplementation("net.fabricmc:fabric-language-kotlin:${project.property("fabric_kotlin_version")}") + modApi("dev.architectury:architectury:6.2.46") // Actual dependencies - modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${rootProject.property("rei_version")}") + modCompileOnly("me.shedaniel:RoughlyEnoughItems-api:${rootProject.property("rei_version")}") { + exclude(module = "architectury") + exclude(module = "architectury-fabric") + } shadowMe("io.github.moulberry:neurepoparser:0.0.1") - shadowMe("com.github.hypfvieh:dbus-java-core:4.1.0") - shadowMe("com.github.hypfvieh:dbus-java-transport-native-unixsocket:4.1.0") + shadowMe("com.github.hypfvieh:dbus-java-core:${rootProject.property("dbus_java_version")}") + shadowMe("com.github.hypfvieh:dbus-java-transport-native-unixsocket:${rootProject.property("dbus_java_version")}") fun ktor(mod: String) = "io.ktor:ktor-$mod-jvm:${project.property("ktor_version")}" transInclude(implementation(ktor("client-core"))!!) @@ -74,7 +83,11 @@ dependencies { modImplementation(include("io.github.cottonmc:LibGui:${project.property("libgui_version")}")!!) // Dev environment preinstalled mods - modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:${project.property("rei_version")}") + modRuntimeOnly("dev.architectury:architectury-fabric:6.2.46") + modRuntimeOnly("me.shedaniel:RoughlyEnoughItems-fabric:${project.property("rei_version")}") { + exclude(module = "architectury") + exclude(module = "architectury-fabric") + } modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:${project.property("devauth_version")}") modRuntimeOnly("maven.modrinth:modmenu:${project.property("modmenu_version")}") @@ -126,7 +139,7 @@ tasks.processResources { ) } filesMatching("**/lang/*.json") { - flattenJson(this) + // flattenJson(this) } } diff --git a/gradle.properties b/gradle.properties index 8cf5228..0cc89e5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,15 +8,15 @@ archives_base_name=notenoughupdates mod_version=1.0.0 maven_group=moe.nea.notenoughupdates -architectury_version=5.10.33 - -fabric_loader_version=0.14.8 -fabric_api_version=0.58.0+1.19 +fabric_loader_version=0.14.9 +fabric_api_version=0.60.0+1.19.2 fabric_kotlin_version=1.8.2+kotlin.1.7.10 yarn_version=1.19.2+build.9 -libgui_version=6.0.0+1.19 -rei_version=9.1.518 +libgui_version=6.1.0+1.19 +rei_version=9.1.537 devauth_version=1.0.0 -modmenu_version=4.0.4 +modmenu_version=4.0.6 ktor_version=2.0.3 + +dbus_java_version=4.2.0 diff --git a/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt b/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt index a2949a7..bf999bd 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/NotEnoughUpdates.kt @@ -5,12 +5,8 @@ import io.ktor.client.* import io.ktor.client.plugins.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.serialization.kotlinx.json.* -import kotlinx.coroutines.* -import kotlinx.serialization.json.Json -import moe.nea.notenoughupdates.commands.registerNeuCommand -import moe.nea.notenoughupdates.dbus.NEUDbusObject -import moe.nea.notenoughupdates.repo.RepoManager -import moe.nea.notenoughupdates.util.ConfigHolder +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 @@ -19,13 +15,18 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents import net.fabricmc.loader.api.FabricLoader import net.fabricmc.loader.api.Version import net.fabricmc.loader.api.metadata.ModMetadata -import net.minecraft.command.CommandRegistryAccess import org.apache.logging.log4j.LogManager import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder -import java.nio.file.Files -import java.nio.file.Path +import kotlinx.coroutines.* +import kotlinx.serialization.json.Json import kotlin.coroutines.EmptyCoroutineContext +import net.minecraft.command.CommandRegistryAccess +import moe.nea.notenoughupdates.commands.registerNeuCommand +import moe.nea.notenoughupdates.dbus.NEUDbusObject import moe.nea.notenoughupdates.features.FeatureManager +import moe.nea.notenoughupdates.repo.RepoManager +import moe.nea.notenoughupdates.util.SBData +import moe.nea.notenoughupdates.util.config.IConfigHolder object NotEnoughUpdates : ModInitializer, ClientModInitializer { const val MOD_ID = "notenoughupdates" @@ -59,7 +60,6 @@ object NotEnoughUpdates : ModInitializer, ClientModInitializer { .build() val coroutineScope = CoroutineScope(EmptyCoroutineContext + CoroutineName("NotEnoughUpdates")) + SupervisorJob(globalJob) - val coroutineScopeIo = coroutineScope + Dispatchers.IO + SupervisorJob(globalJob) private fun registerCommands( dispatcher: CommandDispatcher<FabricClientCommandSource>, @@ -72,8 +72,9 @@ object NotEnoughUpdates : ModInitializer, ClientModInitializer { override fun onInitialize() { dbusConnection.requestBusName("moe.nea.notenoughupdates") dbusConnection.exportObject(NEUDbusObject) - ConfigHolder.registerEvents() + IConfigHolder.registerEvents() RepoManager.initialize() + SBData.init() FeatureManager.autoload() ClientCommandRegistrationCallback.EVENT.register(this::registerCommands) ClientLifecycleEvents.CLIENT_STOPPING.register(ClientLifecycleEvents.ClientStopping { diff --git a/src/main/kotlin/moe/nea/notenoughupdates/commands/rome.kt b/src/main/kotlin/moe/nea/notenoughupdates/commands/rome.kt index 55f2c50..6c75f20 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/commands/rome.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/commands/rome.kt @@ -2,11 +2,12 @@ package moe.nea.notenoughupdates.commands import com.mojang.brigadier.CommandDispatcher import io.github.cottonmc.cotton.gui.client.CottonClientScreen +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource +import net.minecraft.text.Text import moe.nea.notenoughupdates.gui.repoGui import moe.nea.notenoughupdates.repo.RepoManager +import moe.nea.notenoughupdates.util.SBData import moe.nea.notenoughupdates.util.ScreenUtil.setScreenLater -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource -import net.minecraft.text.Text fun neuCommand() = literal("neu") { @@ -27,6 +28,23 @@ fun neuCommand() = literal("neu") { setScreenLater(CottonClientScreen(repoGui())) } } + thenLiteral("dev") { + val sbData = thenLiteral("sbdata") { + thenExecute { + source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.profile", SBData.profileCuteName)) + val locrawInfo = SBData.locraw + if (locrawInfo == null) { + source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.nolocraw")) + } else { + source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.server", locrawInfo.server)) + source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.gametype", locrawInfo.gametype)) + source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.mode", locrawInfo.mode)) + source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.map", locrawInfo.map)) + } + + } + } + } } diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt index 278282e..81dc6fc 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEvent.kt @@ -1,7 +1,36 @@ package moe.nea.notenoughupdates.events +/** + * An event that can be fired by a [NEUEventBus]. + * + * Typically, that event bus is implemented as a companion object + * + * ``` + * class SomeEvent : NEUEvent() { + * companion object : NEUEventBus<SomeEvent>() + * } + * ``` + */ abstract class NEUEvent { + /** + * A [NEUEvent] that can be [cancelled] + */ abstract class Cancellable : NEUEvent() { + /** + * Cancels this is event. + * + * @see cancelled + */ + fun cancel() { + cancelled = true + } + + /** + * Whether this event is cancelled. + * + * Cancelled events will bypass handlers unless otherwise specified and will prevent the action that this + * event was originally fired for. + */ var cancelled: Boolean = false } } diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt index eba71bc..7eb0ecd 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/events/NEUEventBus.kt @@ -1,7 +1,14 @@ package moe.nea.notenoughupdates.events import java.util.concurrent.CopyOnWriteArrayList +import moe.nea.notenoughupdates.NotEnoughUpdates +/** + * A pubsub event bus. + * + * [subscribe] to events [publish]ed on this event bus. + * Subscriptions may not necessarily be delivered in the order or registering. + */ open class NEUEventBus<T : NEUEvent> { data class Handler<T>(val invocation: (T) -> Unit, val receivesCancelled: Boolean) @@ -17,7 +24,11 @@ open class NEUEventBus<T : NEUEvent> { fun publish(event: T): T { for (function in toHandle) { if (function.receivesCancelled || event !is NEUEvent.Cancellable || !event.cancelled) { - function.invocation(event) + try { + function.invocation(event) + } catch (e: Exception) { + NotEnoughUpdates.logger.error("Caught exception during processing event $event", e) + } } } return event diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/ServerChatLineReceivedEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/ServerChatLineReceivedEvent.kt new file mode 100644 index 0000000..681ec6c --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/events/ServerChatLineReceivedEvent.kt @@ -0,0 +1,13 @@ +package moe.nea.notenoughupdates.events + +import net.minecraft.text.Text +import moe.nea.notenoughupdates.util.unformattedString + +/** + * This event gets published whenever the client receives a chat message from the server. + */ +data class ServerChatLineReceivedEvent(val text: Text) : NEUEvent.Cancellable() { + companion object : NEUEventBus<ServerChatLineReceivedEvent>() + + val unformattedString = text.unformattedString +} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/SkyblockServerUpdateEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/SkyblockServerUpdateEvent.kt new file mode 100644 index 0000000..541b4c6 --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/events/SkyblockServerUpdateEvent.kt @@ -0,0 +1,13 @@ +package moe.nea.notenoughupdates.events + +import moe.nea.notenoughupdates.util.Locraw + +/** + * This event gets published whenever `/locraw` is queried and HyPixel returns a location different to the old one. + * + * **N.B.:** This event may get fired multiple times while on the server (for example, first to null, then to the + * correct location). + */ +data class SkyblockServerUpdateEvent(val oldLocraw: Locraw?, val newLocraw: Locraw?) : NEUEvent() { + companion object : NEUEventBus<SkyblockServerUpdateEvent>() +} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt b/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt new file mode 100644 index 0000000..c230c9c --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/events/WorldRenderLastEvent.kt @@ -0,0 +1,22 @@ +package moe.nea.notenoughupdates.events + +import net.minecraft.client.render.Camera +import net.minecraft.client.render.GameRenderer +import net.minecraft.client.render.LightmapTextureManager +import net.minecraft.client.util.math.MatrixStack +import net.minecraft.util.math.Matrix4f + +/** + * This event is called after all world rendering is done, but before any GUI rendering (including hand) has been done. + */ +data class WorldRenderLastEvent( + val matrices: MatrixStack, + val tickDelta: Float, + val renderBlockOutline: Boolean, + val camera: Camera, + val gameRenderer: GameRenderer, + val lightmapTextureManager: LightmapTextureManager, + val positionMatrix: Matrix4f, +) : NEUEvent() { + companion object : NEUEventBus<WorldRenderLastEvent>() +} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt index 766cf1f..0ffaad5 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/features/FeatureManager.kt @@ -1,27 +1,42 @@ package moe.nea.notenoughupdates.features +import kotlinx.serialization.Serializable import kotlinx.serialization.serializer import moe.nea.notenoughupdates.NotEnoughUpdates import moe.nea.notenoughupdates.features.world.FairySouls -import moe.nea.notenoughupdates.util.ConfigHolder +import moe.nea.notenoughupdates.util.config.ConfigHolder object FeatureManager : ConfigHolder<FeatureManager.Config>(serializer(), "features", ::Config) { + @Serializable data class Config( val enabledFeatures: MutableMap<String, Boolean> = mutableMapOf() ) private val features = mutableMapOf<String, NEUFeature>() + private var hasAutoloaded = false + + init { + autoload() + } + fun autoload() { - loadFeature(FairySouls) + synchronized(this) { + if (hasAutoloaded) return + loadFeature(FairySouls) + hasAutoloaded = true + } } fun loadFeature(feature: NEUFeature) { - if (feature.identifier in features) { - NotEnoughUpdates.logger.error("Double registering feature ${feature.identifier}. Ignoring second instance $feature") - return + synchronized(features) { + if (feature.identifier in features) { + NotEnoughUpdates.logger.error("Double registering feature ${feature.identifier}. Ignoring second instance $feature") + return + } + features[feature.identifier] = feature + feature.onLoad() } - features[feature.identifier] = feature } fun isEnabled(identifier: String): Boolean? = diff --git a/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt b/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt index b928f3d..9bd1a1f 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/features/world/FairySouls.kt @@ -1,12 +1,103 @@ package moe.nea.notenoughupdates.features.world +import io.github.moulberry.repo.data.Coordinate +import kotlinx.serialization.Serializable +import kotlinx.serialization.serializer +import net.minecraft.util.math.BlockPos +import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent +import moe.nea.notenoughupdates.events.SkyblockServerUpdateEvent +import moe.nea.notenoughupdates.events.WorldRenderLastEvent import moe.nea.notenoughupdates.features.NEUFeature +import moe.nea.notenoughupdates.repo.RepoManager +import moe.nea.notenoughupdates.util.MC +import moe.nea.notenoughupdates.util.SBData +import moe.nea.notenoughupdates.util.config.ProfileSpecificConfigHolder +import moe.nea.notenoughupdates.util.render.RenderBlockContext.Companion.renderBlocks +import moe.nea.notenoughupdates.util.unformattedString + +val Coordinate.blockPos: BlockPos + get() = BlockPos(x, y, z) + +object FairySouls : NEUFeature, + ProfileSpecificConfigHolder<FairySouls.Config>(serializer(), "fairy-souls.json", ::Config) { + @Serializable + data class Config( + val foundSouls: MutableMap<String, MutableSet<Int>> = mutableMapOf() + ) -object FairySouls : NEUFeature { override val name: String get() = "Fairy Souls" override val identifier: String get() = "fairy-souls" + val playerReach = 5 + val playerReachSquared = playerReach * playerReach + + var currentLocationName: String? = null + var currentLocationSouls: List<Coordinate> = emptyList() + var currentMissingSouls: List<Coordinate> = emptyList() + + fun updateMissingSouls() { + currentMissingSouls = emptyList() + val c = config ?: return + val fi = c.foundSouls[currentLocationName] ?: setOf() + val cms = currentLocationSouls.toMutableList() + fi.asSequence().sortedDescending().filter { it in cms.indices }.forEach { cms.removeAt(it) } + currentMissingSouls = cms + } + + fun updateWorldSouls() { + currentLocationSouls = emptyList() + val loc = currentLocationName ?: return + currentLocationSouls = RepoManager.neuRepo.constants.fairySouls.soulLocations[loc] ?: return + } + + fun findNearestClickableSoul(): Coordinate? { + val player = MC.player ?: return null + val pos = player.pos + val location = SBData.skyblockLocation ?: return null + val soulLocations: List<Coordinate> = + RepoManager.neuRepo.constants.fairySouls.soulLocations[location] ?: return null + return soulLocations + .map { it to it.blockPos.getSquaredDistance(pos) } + .filter { it.second < playerReachSquared } + .minByOrNull { it.second } + ?.first + } + + private fun markNearestSoul() { + val nearestSoul = findNearestClickableSoul() ?: return + val c = config ?: return + val loc = currentLocationName ?: return + val idx = currentLocationSouls.indexOf(nearestSoul) + c.foundSouls.computeIfAbsent(loc) { mutableSetOf() }.add(idx) + markDirty() + updateMissingSouls() + } + + override fun onLoad() { + SkyblockServerUpdateEvent.subscribe { + currentLocationName = it.newLocraw?.skyblockLocation + updateWorldSouls() + updateMissingSouls() + } + ServerChatLineReceivedEvent.subscribe { + when (it.text.unformattedString) { + "You have already found that Fairy Soul!" -> { + markNearestSoul() + } + "SOUL! You found a Fairy Soul!" -> { + markNearestSoul() + } + } + } + WorldRenderLastEvent.subscribe { + renderBlocks(it.camera) { + color(1F, 1F, 0F, 0.8F) + currentMissingSouls.forEach { + block(it.blockPos) + } + } + } } } diff --git a/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt b/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt index 3792d80..a5453a9 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/gui/ConfigGui.kt @@ -9,7 +9,7 @@ import io.github.cottonmc.cotton.gui.widget.data.HorizontalAlignment import io.github.cottonmc.cotton.gui.widget.data.Insets import io.github.cottonmc.cotton.gui.widget.data.VerticalAlignment import moe.nea.notenoughupdates.NotEnoughUpdates -import moe.nea.notenoughupdates.util.ConfigHolder +import moe.nea.notenoughupdates.util.config.ConfigHolder import net.minecraft.text.Text import kotlin.reflect.KMutableProperty1 diff --git a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt new file mode 100644 index 0000000..b6151b9 --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinMessageHandler.kt @@ -0,0 +1,33 @@ +package moe.nea.notenoughupdates.mixins + +import org.spongepowered.asm.mixin.Mixin +import org.spongepowered.asm.mixin.injection.At +import org.spongepowered.asm.mixin.injection.Inject +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import net.minecraft.client.network.message.MessageHandler +import net.minecraft.network.message.MessageType +import net.minecraft.network.message.SignedMessage +import net.minecraft.text.Text +import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent + +@Mixin(MessageHandler::class) +class MixinMessageHandler { + @Inject(method = ["onChatMessage"], at = [At("HEAD")], cancellable = true) + fun onOnChatMessage(message: SignedMessage, params: MessageType.Parameters, ci: CallbackInfo) { + val decoratedText = params.applyChatDecoration(message.unsignedContent.orElse(message.content)) + val event = ServerChatLineReceivedEvent(decoratedText) + if (ServerChatLineReceivedEvent.publish(event).cancelled) { + ci.cancel() + } + } + + @Inject(method = ["onGameMessage"], at = [At("HEAD")], cancellable = true) + fun onOnGameMessage(message: Text, overlay: Boolean, ci: CallbackInfo) { + if (!overlay) { + val event = ServerChatLineReceivedEvent(message) + if (ServerChatLineReceivedEvent.publish(event).cancelled) { + ci.cancel() + } + } + } +} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt new file mode 100644 index 0000000..ac9ea15 --- /dev/null +++ b/src/main/kotlin/moe/nea/notenoughupdates/mixins/MixinWorldRenderer.kt @@ -0,0 +1,41 @@ +package moe.nea.notenoughupdates.mixins + +import org.spongepowered.asm.mixin.Mixin +import org.spongepowered.asm.mixin.injection.At +import org.spongepowered.asm.mixin.injection.Inject +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import net.minecraft.client.render.Camera +import net.minecraft.client.render.GameRenderer +import net.minecraft.client.render.LightmapTextureManager +import net.minecraft.client.render.WorldRenderer +import net.minecraft.client.util.math.MatrixStack +import net.minecraft.util.math.Matrix4f +import moe.nea.notenoughupdates.events.WorldRenderLastEvent + +@Mixin(WorldRenderer::class) +class MixinWorldRenderer { + + @Inject( + method = ["render"], + at = [At("INVOKE", target = "renderChunkDebugInfo", shift = At.Shift.AFTER)], + ) + fun onWorldRenderLast( + matrices: MatrixStack, + tickDelta: Float, + arg2: Long, + renderBlockOutline: Boolean, + camera: Camera, + gameRenderer: GameRenderer, + lightmapTextureManager: LightmapTextureManager, + positionMatrix: Matrix4f, + ci: CallbackInfo + ) { + val event = WorldRenderLastEvent( + matrices, tickDelta, renderBlockOutline, + camera, gameRenderer, lightmapTextureManager, + positionMatrix + ) + WorldRenderLastEvent.publish(event) + } + +} diff --git a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt index 72603d9..26bca51 100644 --- a/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt +++ b/src/main/kotlin/moe/nea/notenoughupdates/repo/RepoManager.kt @@ -9,7 +9,7 @@ import kotlinx.serialization.serializer import moe.nea.notenoughupdates.NotEnoughUpdates import moe.nea.notenoughupdates.NotEnoughUpdates.logger import moe.nea.notenoughupdates.hud.ProgressBar -import moe.nea.notenoughupdates.util.ConfigHolder +import moe.nea.notenoughupdates.util.config.ConfigHolder import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents import net.minecraft.client.MinecraftClient import net.minecraft.network.packet.s2c.play.SynchronizeRecipesS2CPacket diff --git a/src/main/kotlin/moe/nea/notenoughupdates/util/ConfigHolder.kt b/src/main/kotlin/moe/nea/notenoughupdates/util/ConfigHolder.kt deleted file mode 100644 index 50a3d9b..0000000 --- a/src/main/kotlin/moe/nea/notenoughupdates/util/ConfigHolder.kt +++ /dev/null @@ -1,131 +0,0 @@ -package moe.nea.notenoughupdates.util - -import java.io.IOException -import java.nio.file.Path -import java.util.concurrent.CopyOnWriteArrayList -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents -import kotlinx.serialization.KSerializer -import kotlinx.serialization.SerializationException -import kotlin.io.path.exists -import kotlin.io.path.readText -import kotlin.io.path.writeText -import kotlin.reflect.KClass -import net.minecraft.client.MinecraftClient -import net.minecraft.server.command.CommandOutput -import net.minecraft.text.Text -import moe.nea.notenoughupdates.NotEnoughUpdates -import moe.nea.notenoughupdates.events.ScreenOpenEvent - -abstract class ConfigHolder<T>( - val serializer: KSerializer<T>, - val name: String, - val default: () -> T -) { - |
