2023-11-25 21:38:04 +02:00
|
|
|
package com.hypherionmc.craterlib;
|
|
|
|
|
2024-07-05 20:29:10 +02:00
|
|
|
import com.hypherionmc.craterlib.client.NeoForgeClientHelper;
|
2023-11-25 21:38:04 +02:00
|
|
|
import com.hypherionmc.craterlib.common.NeoForgeServerEvents;
|
2024-05-01 18:28:52 +02:00
|
|
|
import com.hypherionmc.craterlib.compat.Vanish;
|
2024-01-02 15:16:13 +02:00
|
|
|
import com.hypherionmc.craterlib.core.networking.CraterPacketNetwork;
|
|
|
|
import com.hypherionmc.craterlib.core.networking.PacketRegistry;
|
|
|
|
import com.hypherionmc.craterlib.core.networking.data.PacketSide;
|
2024-05-01 18:28:52 +02:00
|
|
|
import com.hypherionmc.craterlib.core.platform.ModloaderEnvironment;
|
2024-01-02 15:16:13 +02:00
|
|
|
import com.hypherionmc.craterlib.network.CraterNeoForgeNetworkHandler;
|
2023-11-25 21:38:04 +02:00
|
|
|
import net.neoforged.bus.api.IEventBus;
|
|
|
|
import net.neoforged.fml.common.Mod;
|
2024-07-05 20:29:10 +02:00
|
|
|
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
2023-11-25 21:38:04 +02:00
|
|
|
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
|
2024-01-02 15:16:13 +02:00
|
|
|
import net.neoforged.fml.loading.FMLLoader;
|
2023-11-25 21:38:04 +02:00
|
|
|
import net.neoforged.neoforge.common.NeoForge;
|
|
|
|
|
|
|
|
@Mod(CraterConstants.MOD_ID)
|
|
|
|
public class CraterLib {
|
|
|
|
|
2024-01-02 15:16:13 +02:00
|
|
|
private final PacketRegistry handler;
|
|
|
|
|
2023-11-25 21:38:04 +02:00
|
|
|
public CraterLib(IEventBus eventBus) {
|
|
|
|
NeoForge.EVENT_BUS.register(new NeoForgeServerEvents());
|
2024-05-01 13:26:18 +02:00
|
|
|
eventBus.addListener(this::commonSetup);
|
2024-07-05 20:29:10 +02:00
|
|
|
eventBus.addListener(this::clientSetup);
|
2024-01-02 15:16:13 +02:00
|
|
|
handler = new CraterNeoForgeNetworkHandler(FMLLoader.getDist().isClient() ? PacketSide.CLIENT : PacketSide.SERVER);
|
2024-05-01 18:28:52 +02:00
|
|
|
|
|
|
|
if (ModloaderEnvironment.INSTANCE.isModLoaded("vmod")) {
|
|
|
|
eventBus.register(new Vanish());
|
|
|
|
}
|
2023-11-25 21:38:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void commonSetup(FMLCommonSetupEvent evt) {
|
2024-01-02 15:16:13 +02:00
|
|
|
new CraterPacketNetwork(handler);
|
2024-07-05 20:29:10 +02:00
|
|
|
}
|
2024-05-05 23:07:50 +02:00
|
|
|
|
2024-07-05 20:29:10 +02:00
|
|
|
public void clientSetup(FMLClientSetupEvent evt) {
|
|
|
|
NeoForgeClientHelper.registerClient();
|
2023-11-25 21:38:04 +02:00
|
|
|
}
|
|
|
|
}
|