From 991582f93094f36c94053ce254c63c65e4a8d2af Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 19 Nov 2024 03:12:26 +0300 Subject: [PATCH 1/4] Kotlin for (Neo)Forge --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4c1464ba5..a89aa523a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -139,7 +139,7 @@ dependencies { implementation("net.neoforged:neoforge:$forge_version") testImplementation("org.junit.jupiter:junit-jupiter:${jupiter_version}") - implementation("thedarkcolour:kotlinforforge:$kotlin_for_forge_version") + implementation("thedarkcolour:kotlinforforge-neoforge:$kotlin_for_forge_version") jarJar("ru.dbotthepony.kommons:kommons:[$kommons_version,)") { setTransitive(false) } implementation("ru.dbotthepony.kommons:kommons:[$kommons_version,)") { setTransitive(false) } From 1712f923354fac41c18749701d2a4533506fdc29 Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 19 Nov 2024 03:40:18 +0300 Subject: [PATCH 2/4] Kotlin for Kotlin (switch to KFF loader) --- .../mc/otm/OverdriveThatMatters.java | 272 ------------------ .../mc/otm/OverdriveThatMatters.kt | 239 +++++++++++++++ .../resources/META-INF/neoforge.mods.toml | 4 +- 3 files changed, 241 insertions(+), 274 deletions(-) delete mode 100644 src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java create mode 100644 src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt diff --git a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java b/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java deleted file mode 100644 index 4532dc269..000000000 --- a/src/main/java/ru/dbotthepony/mc/otm/OverdriveThatMatters.java +++ /dev/null @@ -1,272 +0,0 @@ -package ru.dbotthepony.mc.otm; - -import kotlin.KotlinVersion; -import net.minecraft.MethodsReturnNonnullByDefault; -import net.minecraft.resources.ResourceLocation; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.bus.api.EventPriority; -import net.neoforged.bus.api.IEventBus; -import net.neoforged.fml.ModContainer; -import net.neoforged.fml.ModList; -import net.neoforged.fml.common.Mod; -import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; -import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import ru.dbotthepony.mc.otm.android.AndroidResearchDescription; -import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions; -import ru.dbotthepony.mc.otm.android.AndroidResearchManager; -import ru.dbotthepony.mc.otm.android.AndroidResearchResult; -import ru.dbotthepony.mc.otm.android.AndroidResearchResults; -import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature; -import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity; -import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity; -import ru.dbotthepony.mc.otm.capability.MatteryPlayer; -import ru.dbotthepony.mc.otm.capability.drive.DrivePool; -import ru.dbotthepony.mc.otm.client.AndroidAbilityKeyMapping; -import ru.dbotthepony.mc.otm.client.AndroidMenuKeyMapping; -import ru.dbotthepony.mc.otm.client.ClientEventHandlerKt; -import ru.dbotthepony.mc.otm.client.ClientTickHandlerKt; -import ru.dbotthepony.mc.otm.client.MatteryGUI; -import ru.dbotthepony.mc.otm.client.model.ExosuitModel; -import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel; -import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel; -import ru.dbotthepony.mc.otm.client.render.ChartTooltipElement; -import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer; -import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer; -import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer; -import ru.dbotthepony.mc.otm.compat.curios.CuriosCompatKt; -import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu; -import ru.dbotthepony.mc.otm.config.AndroidConfig; -import ru.dbotthepony.mc.otm.config.CablesConfig; -import ru.dbotthepony.mc.otm.config.ClientConfig; -import ru.dbotthepony.mc.otm.config.ExopackConfig; -import ru.dbotthepony.mc.otm.config.ItemsConfig; -import ru.dbotthepony.mc.otm.config.MachinesConfig; -import ru.dbotthepony.mc.otm.config.ServerConfig; -import ru.dbotthepony.mc.otm.config.ToolsConfig; -import ru.dbotthepony.mc.otm.data.DecimalProvider; -import ru.dbotthepony.mc.otm.item.ChestUpgraderItem; -import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem; -import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem; -import ru.dbotthepony.mc.otm.item.QuantumBatteryItem; -import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem; -import ru.dbotthepony.mc.otm.matter.AbstractRegistryAction; -import ru.dbotthepony.mc.otm.matter.IMatterFunction; -import ru.dbotthepony.mc.otm.matter.MatterManager; -import ru.dbotthepony.mc.otm.network.*; -import ru.dbotthepony.mc.otm.registry.*; -import ru.dbotthepony.mc.otm.server.MCommands; -import ru.dbotthepony.mc.otm.storage.StorageStack; -import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger; -import top.theillusivec4.curios.api.CuriosApi; - -import static net.neoforged.neoforge.common.NeoForge.EVENT_BUS; - -import javax.annotation.ParametersAreNonnullByDefault; - -// The value here should match an entry in the META-INF/mods.toml file -@Mod(OverdriveThatMatters.MOD_ID) -@ParametersAreNonnullByDefault -@MethodsReturnNonnullByDefault -public final class OverdriveThatMatters { - // Directly reference a log4j logger. - public static final String MOD_ID = "overdrive_that_matters"; - private static final Logger LOGGER = LogManager.getLogger(); - public static OverdriveThatMatters INSTANCE; - public static ResourceLocation loc(String path) { - return ResourceLocation.fromNamespaceAndPath(MOD_ID, path); - } - - private static void checkIfKotlinIsInstalled() { - if (!KotlinVersion.CURRENT.isAtLeast(2, 0, 0)) { - throw new UnsupportedClassVersionError("Installed kotlin version is " + KotlinVersion.CURRENT + ", when at least 2.0.0 is required."); - } - } - - public OverdriveThatMatters(IEventBus bus, Dist dist, ModContainer container) { - if (INSTANCE != null) { - throw new IllegalStateException("wei wei wei... hello?"); - } - - try { - checkIfKotlinIsInstalled(); - } catch (Throwable err) { - if (err instanceof NoClassDefFoundError) { - for (int i = 0; i < 16; i++) - LOGGER.fatal("Overdrive That Matters requires Kotlin to be installed, get Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge"); - - LOGGER.fatal("Overdrive That Matters requires Kotlin to be installed, get Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge", err); - throw new RuntimeException("Overdrive That Matters requires Kotlin to be installed, get Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge"); - } - - for (int i = 0; i < 16; i++) - LOGGER.fatal("Overdrive That Matters' Kotlin version is not satisfied, get newer Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge"); - - LOGGER.fatal("Overdrive That Matters' Kotlin version is not satisfied, get newer Kotlin for Forge from https://github.com/thedarkcolour/KotlinForForge", err); - - throw err; - } - - INSTANCE = this; - - MBlocks.INSTANCE.register(bus); - MFluids.INSTANCE.register(bus); - MBlockEntities.INSTANCE.register(bus); - MEntityTypes.INSTANCE.register(bus); - MMenus.INSTANCE.register(bus); - MItems.INSTANCE.register(bus); - AndroidFeatures.INSTANCE.register(bus); - MSoundEvents.INSTANCE.register(bus); - LootModifiers.INSTANCE.register(bus); - MItemFunctionTypes.INSTANCE.register(bus); - MLootItemConditions.INSTANCE.register(bus); - MRecipes.INSTANCE.register(bus); - MDataComponentTypes.INSTANCE.register(bus); - MArmorMaterials.INSTANCE.register(bus); - MCriteriaTriggers.INSTANCE.register(bus); - MStats.INSTANCE.register(bus); - MWorldGenFeatures.INSTANCE.register(bus); - CommandArgumentTypes.INSTANCE.register(bus); - - StorageStack.Companion.register(bus); - MatteryChestMenu.Companion.register(bus); - - MCreativeTabs.INSTANCE.initialize(bus); - - bus.addListener(NetworkPacketsKt::registerNetworkPackets); - - DecimalProvider.Companion.register(bus); - AndroidResearchDescription.Companion.register(bus); - AndroidResearchDescriptions.INSTANCE.register(bus); - AndroidResearchResult.Companion.register(bus); - AndroidResearchResults.INSTANCE.register(bus); - - AbstractRegistryAction.Companion.register(bus); - IMatterFunction.Companion.register(bus); - - MRegistry.INSTANCE.initialize(bus); - MatterManager.INSTANCE.initialize(bus); - - bus.addListener(EventPriority.HIGHEST, this::setup); - bus.addListener(EventPriority.NORMAL, this::setupClient); - - if (dist == Dist.CLIENT) { - bus.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping.INSTANCE::register); - bus.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping.INSTANCE::register); - bus.addListener(EventPriority.NORMAL, TritaniumArmorModel::register); - bus.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register); - bus.addListener(EventPriority.NORMAL, MCreativeTabs.INSTANCE::register); - - bus.addListener(EventPriority.NORMAL, BatteryBankRenderer.Companion::onRegisterAdditionalModels); - bus.addListener(EventPriority.NORMAL, MatterBatteryBankRenderer.Companion::onRegisterAdditionalModels); - - bus.addListener(EventPriority.NORMAL, ChartTooltipElement.Companion::register); - - MBlockColors.INSTANCE.register(bus); - } - - ClientConfig.INSTANCE.register(container); - ServerConfig.INSTANCE.register(container); - CablesConfig.INSTANCE.register(container); - AndroidConfig.INSTANCE.register(container); - ExopackConfig.INSTANCE.register(container); - ItemsConfig.INSTANCE.register(container); - MachinesConfig.INSTANCE.register(container); - ToolsConfig.INSTANCE.register(container); - } - - private void setup(final FMLCommonSetupEvent event) { - EVENT_BUS.addListener(EventPriority.NORMAL, DrivePool.INSTANCE::onWorldSave); - - EVENT_BUS.addListener(EventPriority.HIGHEST, GlobalEventHandlerKt::onServerStopped); - EVENT_BUS.addListener(EventPriority.HIGHEST, GlobalEventHandlerKt::onServerStopping); - EVENT_BUS.addListener(EventPriority.HIGHEST, GlobalEventHandlerKt::onServerStarting); - EVENT_BUS.addListener(EventPriority.HIGH, GlobalEventHandlerKt::onLevelTickPre); - EVENT_BUS.addListener(EventPriority.LOWEST, GlobalEventHandlerKt::onLevelTickPost); - EVENT_BUS.addListener(EventPriority.HIGH, GlobalEventHandlerKt::onServerTickPre); - EVENT_BUS.addListener(EventPriority.LOWEST, GlobalEventHandlerKt::onServerTickPost); - - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerTickPre); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerTickPost); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::isMobEffectApplicable); - EVENT_BUS.addListener(EventPriority.LOW, MatteryPlayer.Companion::onHurtEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerChangeDimensionEvent); - EVENT_BUS.addListener(EventPriority.LOWEST, MatteryPlayer.Companion::onPlayerDeath); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerCloneEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerSpawnPhantoms); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onStartTracking); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onStopTracking); - - EVENT_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::tick); - EVENT_BUS.addListener(EventPriority.LOWEST, PortableCondensationDriveItem.Companion::onPickupEvent); - - EVENT_BUS.addListener(EventPriority.NORMAL, AndroidResearchManager.INSTANCE::reloadEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, AndroidResearchManager.INSTANCE::syncEvent); - - EVENT_BUS.addListener(EventPriority.NORMAL, MatterManager.INSTANCE::reloadEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, MatterManager.INSTANCE::onServerStarted); - EVENT_BUS.addListener(EventPriority.NORMAL, MatterManager.INSTANCE::onDataPackSync); - EVENT_BUS.addListener(EventPriority.NORMAL, MatterManager.INSTANCE::addCommands); - - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onServerStopping); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onLevelUnload); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onWatch); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onForget); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::playerDisconnected); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::postLevelTick); - - EVENT_BUS.addListener(EventPriority.LOWEST, KillAsAndroidTrigger.INSTANCE::onKill); - - EVENT_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath); - EVENT_BUS.addListener(EventPriority.HIGH, TritaniumArmorItem.Companion::onHurt); - - EVENT_BUS.addListener(EventPriority.NORMAL, ExplosiveHammerItem.Companion::onLeftClickBlock); - - EVENT_BUS.addListener(EventPriority.NORMAL, ChestUpgraderItem.Companion::onEntityInteract); - - EVENT_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged); - - EVENT_BUS.addListener(EventPriority.NORMAL, MCommands.INSTANCE::register); - - if (ModList.get().isLoaded(CuriosApi.MODID)) { - EVENT_BUS.addListener(EventPriority.NORMAL, CuriosCompatKt::onCuriosSlotModifiersUpdated); - } - } - - private void setupClient(final FMLClientSetupEvent event) { - EVENT_BUS.addListener(EventPriority.NORMAL, MatterManager.INSTANCE::tooltipEvent); - - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryGUI.INSTANCE::onScreenRender); - EVENT_BUS.addListener(EventPriority.LOWEST, MatteryGUI.INSTANCE::onOpenGUIEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, MatteryGUI.INSTANCE::onRenderGuiEvent); - EVENT_BUS.addListener(EventPriority.HIGH, MatteryGUI.INSTANCE::onLayerRenderEvent); - - EVENT_BUS.addListener(EventPriority.NORMAL, ShockwaveRenderer.INSTANCE::onRender); - - EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onMovementInputUpdate); - EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onScreenOpen); - EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onPostScreenInit); - EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onMouseDragged); - EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::onMouseScrolled); - EVENT_BUS.addListener(EventPriority.LOWEST, ClientTickHandlerKt::onClientTickPre); - EVENT_BUS.addListener(EventPriority.LOWEST, ClientTickHandlerKt::onClientTickPost); - EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientConnected); - EVENT_BUS.addListener(EventPriority.HIGHEST, ClientTickHandlerKt::onClientDisconnected); - EVENT_BUS.addListener(EventPriority.NORMAL, ClientTickHandlerKt::onClientPostRender); - EVENT_BUS.addListener(EventPriority.NORMAL, ClientEventHandlerKt::tooltipEvent); - - EVENT_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::clientDisconnect); - - EVENT_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping.INSTANCE::onRenderGuiEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping.INSTANCE::onMouseClick); - - EVENT_BUS.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping.INSTANCE::onRenderGuiEvent); - EVENT_BUS.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping.INSTANCE::onRenderLevel); - - EVENT_BUS.addListener(EventPriority.NORMAL, ExosuitModel::onPlayerRendered); - - event.enqueueWork(GlobalEventHandlerKt::recordClientThread); - event.enqueueWork(ClientTickHandlerKt::createCursors); - } -} diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt new file mode 100644 index 000000000..4a793d469 --- /dev/null +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/OverdriveThatMatters.kt @@ -0,0 +1,239 @@ +package ru.dbotthepony.mc.otm + +import net.minecraft.resources.ResourceLocation +import net.neoforged.api.distmarker.Dist +import net.neoforged.bus.api.EventPriority +import net.neoforged.fml.common.Mod +import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent +import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent +import ru.dbotthepony.mc.otm.android.AndroidResearchDescription +import ru.dbotthepony.mc.otm.android.AndroidResearchDescriptions +import ru.dbotthepony.mc.otm.android.AndroidResearchManager +import ru.dbotthepony.mc.otm.android.AndroidResearchResult +import ru.dbotthepony.mc.otm.android.AndroidResearchResults +import ru.dbotthepony.mc.otm.android.feature.EnderTeleporterFeature +import ru.dbotthepony.mc.otm.block.entity.MatteryBlockEntity +import ru.dbotthepony.mc.otm.block.entity.decorative.DevChestBlockEntity +import ru.dbotthepony.mc.otm.capability.MatteryPlayer +import ru.dbotthepony.mc.otm.capability.drive.DrivePool +import ru.dbotthepony.mc.otm.client.AndroidAbilityKeyMapping +import ru.dbotthepony.mc.otm.client.AndroidMenuKeyMapping +import ru.dbotthepony.mc.otm.client.MatteryGUI +import ru.dbotthepony.mc.otm.client.createCursors +import ru.dbotthepony.mc.otm.client.model.ExosuitModel +import ru.dbotthepony.mc.otm.client.model.GravitationStabilizerModel +import ru.dbotthepony.mc.otm.client.model.TritaniumArmorModel +import ru.dbotthepony.mc.otm.client.onMovementInputUpdate +import ru.dbotthepony.mc.otm.client.onScreenOpen +import ru.dbotthepony.mc.otm.client.onPostScreenInit +import ru.dbotthepony.mc.otm.client.onMouseDragged +import ru.dbotthepony.mc.otm.client.onMouseScrolled +import ru.dbotthepony.mc.otm.client.onClientTickPre +import ru.dbotthepony.mc.otm.client.onClientTickPost +import ru.dbotthepony.mc.otm.client.onClientConnected +import ru.dbotthepony.mc.otm.client.onClientDisconnected +import ru.dbotthepony.mc.otm.client.onClientPostRender +import ru.dbotthepony.mc.otm.client.tooltipEvent +import ru.dbotthepony.mc.otm.client.render.ChartTooltipElement +import ru.dbotthepony.mc.otm.client.render.ShockwaveRenderer +import ru.dbotthepony.mc.otm.client.render.blockentity.BatteryBankRenderer +import ru.dbotthepony.mc.otm.client.render.blockentity.MatterBatteryBankRenderer +import ru.dbotthepony.mc.otm.compat.curios.isCuriosLoaded +import ru.dbotthepony.mc.otm.compat.curios.onCuriosSlotModifiersUpdated +import ru.dbotthepony.mc.otm.compat.vanilla.MatteryChestMenu +import ru.dbotthepony.mc.otm.config.AndroidConfig +import ru.dbotthepony.mc.otm.config.CablesConfig +import ru.dbotthepony.mc.otm.config.ClientConfig +import ru.dbotthepony.mc.otm.config.ExopackConfig +import ru.dbotthepony.mc.otm.config.ItemsConfig +import ru.dbotthepony.mc.otm.config.MachinesConfig +import ru.dbotthepony.mc.otm.config.ServerConfig +import ru.dbotthepony.mc.otm.config.ToolsConfig +import ru.dbotthepony.mc.otm.data.DecimalProvider +import ru.dbotthepony.mc.otm.item.ChestUpgraderItem +import ru.dbotthepony.mc.otm.item.tool.ExplosiveHammerItem +import ru.dbotthepony.mc.otm.item.armor.TritaniumArmorItem +import ru.dbotthepony.mc.otm.item.QuantumBatteryItem +import ru.dbotthepony.mc.otm.item.PortableCondensationDriveItem +import ru.dbotthepony.mc.otm.matter.AbstractRegistryAction +import ru.dbotthepony.mc.otm.matter.IMatterFunction +import ru.dbotthepony.mc.otm.matter.MatterManager +import ru.dbotthepony.mc.otm.network.* +import ru.dbotthepony.mc.otm.registry.* +import ru.dbotthepony.mc.otm.server.MCommands +import ru.dbotthepony.mc.otm.storage.StorageStack +import ru.dbotthepony.mc.otm.triggers.KillAsAndroidTrigger +import thedarkcolour.kotlinforforge.neoforge.forge.DIST +import thedarkcolour.kotlinforforge.neoforge.forge.FORGE_BUS +import thedarkcolour.kotlinforforge.neoforge.forge.LOADING_CONTEXT +import thedarkcolour.kotlinforforge.neoforge.forge.MOD_BUS + +@Mod(OverdriveThatMatters.MOD_ID) +object OverdriveThatMatters { + const val MOD_ID = "overdrive_that_matters" + + @JvmStatic + fun loc(path: String): ResourceLocation = ResourceLocation.fromNamespaceAndPath(MOD_ID, path) + + init { + MBlocks.register(MOD_BUS) + MFluids.register(MOD_BUS) + MBlockEntities.register(MOD_BUS) + MEntityTypes.register(MOD_BUS) + MMenus.register(MOD_BUS) + MItems.register(MOD_BUS) + AndroidFeatures.register(MOD_BUS) + MSoundEvents.register(MOD_BUS) + LootModifiers.register(MOD_BUS) + MItemFunctionTypes.register(MOD_BUS) + MLootItemConditions.register(MOD_BUS) + MRecipes.register(MOD_BUS) + MDataComponentTypes.register(MOD_BUS) + MArmorMaterials.register(MOD_BUS) + MCriteriaTriggers.register(MOD_BUS) + MStats.register(MOD_BUS) + MWorldGenFeatures.register(MOD_BUS) + CommandArgumentTypes.register(MOD_BUS) + + StorageStack.Companion.register(MOD_BUS) + MatteryChestMenu.Companion.register(MOD_BUS) + + MCreativeTabs.initialize(MOD_BUS) + + MOD_BUS.addListener(::registerNetworkPackets) + + DecimalProvider.Companion.register(MOD_BUS) + AndroidResearchDescription.Companion.register(MOD_BUS) + AndroidResearchDescriptions.register(MOD_BUS) + AndroidResearchResult.Companion.register(MOD_BUS) + AndroidResearchResults.register(MOD_BUS) + + AbstractRegistryAction.Companion.register(MOD_BUS) + IMatterFunction.Companion.register(MOD_BUS) + + MRegistry.initialize(MOD_BUS) + MatterManager.initialize(MOD_BUS) + + MOD_BUS.addListener(EventPriority.HIGHEST, this::setup) + MOD_BUS.addListener(EventPriority.NORMAL, this::setupClient) + + if (DIST == Dist.CLIENT) { + MOD_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping::register) + MOD_BUS.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping::register) + MOD_BUS.addListener(EventPriority.NORMAL, TritaniumArmorModel::register) + MOD_BUS.addListener(EventPriority.NORMAL, GravitationStabilizerModel::register) + MOD_BUS.addListener(EventPriority.NORMAL, MCreativeTabs::register) + + MOD_BUS.addListener(EventPriority.NORMAL, BatteryBankRenderer.Companion::onRegisterAdditionalModels) + MOD_BUS.addListener(EventPriority.NORMAL, MatterBatteryBankRenderer.Companion::onRegisterAdditionalModels) + + MOD_BUS.addListener(EventPriority.NORMAL, ChartTooltipElement.Companion::register) + + MBlockColors.register(MOD_BUS) + } + + val container = LOADING_CONTEXT.activeContainer + ClientConfig.register(container) + ServerConfig.register(container) + CablesConfig.register(container) + AndroidConfig.register(container) + ExopackConfig.register(container) + ItemsConfig.register(container) + MachinesConfig.register(container) + ToolsConfig.register(container) + } + + private fun setup(event: FMLCommonSetupEvent) { + FORGE_BUS.addListener(EventPriority.NORMAL, DrivePool::onWorldSave) + + FORGE_BUS.addListener(EventPriority.HIGHEST, ::onServerStopped) + FORGE_BUS.addListener(EventPriority.HIGHEST, ::onServerStopping) + FORGE_BUS.addListener(EventPriority.HIGHEST, ::onServerStarting) + FORGE_BUS.addListener(EventPriority.HIGH, ::onLevelTickPre) + FORGE_BUS.addListener(EventPriority.LOWEST, ::onLevelTickPost) + FORGE_BUS.addListener(EventPriority.HIGH, ::onServerTickPre) + FORGE_BUS.addListener(EventPriority.LOWEST, ::onServerTickPost) + + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerTickPre) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerTickPost) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::isMobEffectApplicable) + FORGE_BUS.addListener(EventPriority.LOW, MatteryPlayer.Companion::onHurtEvent) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerChangeDimensionEvent) + FORGE_BUS.addListener(EventPriority.LOWEST, MatteryPlayer.Companion::onPlayerDeath) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerCloneEvent) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onPlayerSpawnPhantoms) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onStartTracking) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryPlayer.Companion::onStopTracking) + + FORGE_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::tick) + FORGE_BUS.addListener(EventPriority.LOWEST, PortableCondensationDriveItem.Companion::onPickupEvent) + + FORGE_BUS.addListener(EventPriority.NORMAL, AndroidResearchManager::reloadEvent) + FORGE_BUS.addListener(EventPriority.NORMAL, AndroidResearchManager::syncEvent) + + FORGE_BUS.addListener(EventPriority.NORMAL, MatterManager::reloadEvent) + FORGE_BUS.addListener(EventPriority.NORMAL, MatterManager::onServerStarted) + FORGE_BUS.addListener(EventPriority.NORMAL, MatterManager::onDataPackSync) + FORGE_BUS.addListener(EventPriority.NORMAL, MatterManager::addCommands) + + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onServerStopping) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onLevelUnload) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onWatch) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::onForget) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::playerDisconnected) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryBlockEntity.Companion::postLevelTick) + + FORGE_BUS.addListener(EventPriority.LOWEST, KillAsAndroidTrigger::onKill) + + FORGE_BUS.addListener(EventPriority.NORMAL, EnderTeleporterFeature.Companion::onEntityDeath) + FORGE_BUS.addListener(EventPriority.HIGH, TritaniumArmorItem.Companion::onHurt) + + FORGE_BUS.addListener(EventPriority.NORMAL, ExplosiveHammerItem.Companion::onLeftClickBlock) + + FORGE_BUS.addListener(EventPriority.NORMAL, ChestUpgraderItem.Companion::onEntityInteract) + + FORGE_BUS.addListener(EventPriority.NORMAL, DevChestBlockEntity.Companion::mappingsChanged) + + FORGE_BUS.addListener(EventPriority.NORMAL, MCommands::register) + + if (isCuriosLoaded) { + FORGE_BUS.addListener(EventPriority.NORMAL, ::onCuriosSlotModifiersUpdated) + } + } + + private fun setupClient(event: FMLClientSetupEvent) { + FORGE_BUS.addListener(EventPriority.NORMAL, MatterManager::tooltipEvent) + + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryGUI::onScreenRender) + FORGE_BUS.addListener(EventPriority.LOWEST, MatteryGUI::onOpenGUIEvent) + FORGE_BUS.addListener(EventPriority.NORMAL, MatteryGUI::onRenderGuiEvent) + FORGE_BUS.addListener(EventPriority.HIGH, MatteryGUI::onLayerRenderEvent) + + FORGE_BUS.addListener(EventPriority.NORMAL, ShockwaveRenderer::onRender) + + FORGE_BUS.addListener(EventPriority.NORMAL, ::onMovementInputUpdate) + FORGE_BUS.addListener(EventPriority.NORMAL, ::onScreenOpen) + FORGE_BUS.addListener(EventPriority.NORMAL, ::onPostScreenInit) + FORGE_BUS.addListener(EventPriority.NORMAL, ::onMouseDragged) + FORGE_BUS.addListener(EventPriority.NORMAL, ::onMouseScrolled) + FORGE_BUS.addListener(EventPriority.LOWEST, ::onClientTickPre) + FORGE_BUS.addListener(EventPriority.LOWEST, ::onClientTickPost) + FORGE_BUS.addListener(EventPriority.HIGHEST, ::onClientConnected) + FORGE_BUS.addListener(EventPriority.HIGHEST, ::onClientDisconnected) + FORGE_BUS.addListener(EventPriority.NORMAL, ::onClientPostRender) + FORGE_BUS.addListener(EventPriority.NORMAL, ::tooltipEvent) + + FORGE_BUS.addListener(EventPriority.NORMAL, QuantumBatteryItem.Companion::clientDisconnect) + + FORGE_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping::onRenderGuiEvent) + FORGE_BUS.addListener(EventPriority.NORMAL, AndroidMenuKeyMapping::onMouseClick) + + FORGE_BUS.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping::onRenderGuiEvent) + FORGE_BUS.addListener(EventPriority.NORMAL, AndroidAbilityKeyMapping::onRenderLevel) + + FORGE_BUS.addListener(EventPriority.NORMAL, ExosuitModel::onPlayerRendered) + + event.enqueueWork(::recordClientThread) + event.enqueueWork(::createCursors) + } +} diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index 88d242677..486c9c61a 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -4,9 +4,9 @@ # Note that there are a couple of TOML lists in this file. # Find more information on toml format here: https://github.com/toml-lang/toml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml -modLoader="javafml" #mandatory +modLoader="kotlinforforge" #mandatory # A version range to match for said mod loader - for regular FML @Mod it will be the forge version -loaderVersion="[4,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. +loaderVersion="[5.5,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions. # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. license="2 Clause BSD" From 3b758def8d905a58735d5519b70792f8b970a40d Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 19 Nov 2024 03:42:46 +0300 Subject: [PATCH 3/4] change worldedit file to neoforge compatible one FINALLY 0 WARNINGS IN RUNCLIENT --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index db2f30aa3..22114a8e4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -31,7 +31,7 @@ resourceful_lib_id=4598948 resourceful_config_id=4576455 jade_id=5591256 configured_id=4462894 -worldedit_id=4807512 +worldedit_id=5830452 item_borders_id=5591010 iceberg_id=5750025 prism_lib_id=5625115 From 8d0aa38b91d94b481ed2746c2b7be16ee41250ae Mon Sep 17 00:00:00 2001 From: YuRaNnNzZZ Date: Tue, 19 Nov 2024 04:37:18 +0300 Subject: [PATCH 4/4] it's not static anymore ??? --- src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt index 9e101a00d..355a7b686 100644 --- a/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt +++ b/src/data/kotlin/ru/dbotthepony/mc/otm/datagen/DataGen.kt @@ -482,7 +482,6 @@ object DataGen { } @SubscribeEvent - @JvmStatic @Suppress("unused") fun onGatherData(event: GatherDataEvent) { val blockModelProvider = MatteryBlockModelProvider(event)