mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-29 04:09:59 -05:00
Backport #148 (LifecycleEvent.SETUP) to 1.16
* Add LifecycleEvent.SETUP for manipulating things after normal initialization * Improve javadocs * Fix broken english * Update common/src/main/java/dev/architectury/event/events/common/LifecycleEvent.java Co-authored-by: BasiqueEvangelist <basiqueevangelist@yandex.ru> Signed-off-by: Max <maxh2709@gmail.com>
This commit is contained in:
@@ -88,6 +88,16 @@ public interface LifecycleEvent {
|
||||
* @see ServerWorldState#act(Level)
|
||||
*/
|
||||
Event<ServerWorldState> SERVER_WORLD_SAVE = EventFactory.createLoop();
|
||||
/**
|
||||
* Invoked once common setup has begun.
|
||||
* <p> This happens during {@code FMLCommonSetupEvent} on Forge,
|
||||
* or when Architectury API's client/server entrypoint initialises on Fabric.
|
||||
* <p>
|
||||
* 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<Runnable> SETUP = EventFactory.createLoop();
|
||||
|
||||
interface InstanceState<T> {
|
||||
/**
|
||||
|
||||
@@ -48,6 +48,10 @@ public interface ClientLifecycleEvent {
|
||||
* Invoked once client setup has begun.
|
||||
* <p> This happens during {@code FMLClientSetupEvent} on Forge,
|
||||
* or when Architectury API's client entrypoint initialises on Fabric.
|
||||
* <p>
|
||||
* 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<ClientState> CLIENT_SETUP = EventFactory.createLoop();
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
],
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user