diff --git a/common/src/main/java/me/shedaniel/architectury/event/events/LifecycleEvent.java b/common/src/main/java/me/shedaniel/architectury/event/events/LifecycleEvent.java index 1a5814f2..71400f24 100644 --- a/common/src/main/java/me/shedaniel/architectury/event/events/LifecycleEvent.java +++ b/common/src/main/java/me/shedaniel/architectury/event/events/LifecycleEvent.java @@ -88,6 +88,16 @@ public interface LifecycleEvent { * @see ServerWorldState#act(Level) */ Event SERVER_WORLD_SAVE = EventFactory.createLoop(); + /** + * Invoked once common setup has begun. + *

This happens during {@code FMLCommonSetupEvent} on Forge, + * or when Architectury API's client/server entrypoint initialises on Fabric. + *

+ * Registries should have been initialised by this point, but there + * are no such guarantees, as you can modify the registry beyond this point + * on non-Forge environments. + */ + Event SETUP = EventFactory.createLoop(); interface InstanceState { /** diff --git a/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java b/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java index 5fc8a130..9fe11962 100644 --- a/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java +++ b/common/src/main/java/me/shedaniel/architectury/event/events/client/ClientLifecycleEvent.java @@ -48,6 +48,10 @@ public interface ClientLifecycleEvent { * Invoked once client setup has begun. *

This happens during {@code FMLClientSetupEvent} on Forge, * or when Architectury API's client entrypoint initialises on Fabric. + *

+ * Registries should have been initialised by this point, but there + * are no such guarantees, as you can modify the registry beyond this point + * on non-Forge environments. */ Event CLIENT_SETUP = EventFactory.createLoop(); diff --git a/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java b/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java index a15b5aab..1954f44d 100644 --- a/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java +++ b/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyClient.java @@ -19,12 +19,14 @@ package me.shedaniel.architectury.init.fabric; +import me.shedaniel.architectury.event.events.LifecycleEvent; import me.shedaniel.architectury.event.events.client.ClientLifecycleEvent; import me.shedaniel.architectury.networking.fabric.SpawnEntityPacket; import net.minecraft.client.Minecraft; public class ArchitecturyClient { public static void init() { + LifecycleEvent.SETUP.invoker().run(); ClientLifecycleEvent.CLIENT_SETUP.invoker().stateChanged(Minecraft.getInstance()); SpawnEntityPacket.Client.register(); diff --git a/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyServer.java b/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyServer.java new file mode 100644 index 00000000..bfcfe2d3 --- /dev/null +++ b/fabric/src/main/java/me/shedaniel/architectury/init/fabric/ArchitecturyServer.java @@ -0,0 +1,28 @@ +/* + * This file is part of architectury. + * Copyright (C) 2020, 2021 architectury + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package me.shedaniel.architectury.init.fabric; + +import me.shedaniel.architectury.event.events.LifecycleEvent; + +public class ArchitecturyServer { + public static void init() { + LifecycleEvent.SETUP.invoker().run(); + } +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 286770df..fd716cc1 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -22,6 +22,9 @@ "main": [ "me.shedaniel.architectury.utils.fabric.GameInstanceImpl::init" ], + "server": [ + "me.shedaniel.architectury.init.fabric.ArchitecturyServer::init" + ], "client": [ "me.shedaniel.architectury.init.fabric.ArchitecturyClient::init" ], diff --git a/forge/src/main/java/me/shedaniel/architectury/event/forge/EventHandlerImplCommon.java b/forge/src/main/java/me/shedaniel/architectury/event/forge/EventHandlerImplCommon.java index 22773053..2ef14d29 100644 --- a/forge/src/main/java/me/shedaniel/architectury/event/forge/EventHandlerImplCommon.java +++ b/forge/src/main/java/me/shedaniel/architectury/event/forge/EventHandlerImplCommon.java @@ -58,6 +58,7 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.LogicalSide; +import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.event.server.*; import net.minecraftforge.fml.server.ServerLifecycleHooks; @@ -396,6 +397,9 @@ public class EventHandlerImplCommon { } public static class ModBasedEventHandler { - + @SubscribeEvent(priority = EventPriority.HIGH) + public static void event(FMLCommonSetupEvent event) { + LifecycleEvent.SETUP.invoker().run(); + } } } diff --git a/gradle.properties b/gradle.properties index e81cbe9f..4d03d285 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ supported_version=1.16.4/5 archives_base_name=architectury archives_base_name_snapshot=architectury-snapshot -base_version=1.26 +base_version=1.27 maven_group=me.shedaniel fabric_loader_version=0.11.1