mirror of
https://github.com/lukasabbe/bookshelf-inspector.git
synced 2026-04-30 10:40:53 +00:00
mabye i have goten somewhere
This commit is contained in:
+2
-5
@@ -1,17 +1,14 @@
|
||||
package com.lukasabbe.bookshelfinspector;
|
||||
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
|
||||
@Mod(Constants.MOD_ID)
|
||||
@Mod(value = Constants.MOD_ID)
|
||||
public class BookshelfInspectorNeoForge {
|
||||
|
||||
public BookshelfInspectorNeoForge(IEventBus eventBus) {
|
||||
EventHandler.init();
|
||||
EventHandler.initServer();
|
||||
eventBus.addListener(NetworkHandler::registerPayloads);
|
||||
BookshelfInspector.init();
|
||||
ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> (client, parent) -> ClothConfigGenerator.createConfig(parent));
|
||||
}
|
||||
}
|
||||
+4
@@ -2,11 +2,15 @@ package com.lukasabbe.bookshelfinspector;
|
||||
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.bus.api.IEventBus;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
|
||||
@Mod(value = Constants.MOD_ID, dist = Dist.CLIENT)
|
||||
public class BookshelfInspectorNeoForgeClient {
|
||||
public BookshelfInspectorNeoForgeClient(IEventBus bus) {
|
||||
EventHandler.initClient();
|
||||
BookshelfInspectorClient.clientInit();
|
||||
ModLoadingContext.get().registerExtensionPoint(IConfigScreenFactory.class, () -> (client, parent) -> ClothConfigGenerator.createConfig(parent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,12 @@ public class EventHandler {
|
||||
public static List<OnPlayerJoinEvent> playerJoinEvents = new ArrayList<>();
|
||||
public static List<OnPlayerDisconnectEvent> playerDisconnectEvents = new ArrayList<>();
|
||||
|
||||
public static void init(){
|
||||
NeoForge.EVENT_BUS.addListener(EventHandler::onJoin);
|
||||
public static void initClient(){
|
||||
NeoForge.EVENT_BUS.addListener(EventHandler::onDisconnect);
|
||||
}
|
||||
public static void initServer(){
|
||||
NeoForge.EVENT_BUS.addListener(EventHandler::onJoin);
|
||||
}
|
||||
|
||||
private static void onJoin(PlayerEvent.PlayerLoggedInEvent event){
|
||||
playerJoinEvents.forEach(onPlayerJoinEvent -> onPlayerJoinEvent.onPlayerJoin((ServerPlayer) event.getEntity(),event.getEntity().getServer()));
|
||||
|
||||
@@ -15,16 +15,6 @@ public class NetworkHandler {
|
||||
@SubscribeEvent
|
||||
public static void registerPayloads(final RegisterPayloadHandlersEvent event){
|
||||
final PayloadRegistrar registrar = event.registrar("1");
|
||||
registrar.playToServer(
|
||||
BookShelfInventoryRequestPayload.ID,
|
||||
BookShelfInventoryRequestPayload.CODEC,
|
||||
((payload, context) -> BookshelfInspector.networkHandlers.bookShelfInventoryRequestServerPayloadHandler.receive(payload, (ServerPlayer) context.player()))
|
||||
);
|
||||
registrar.playToServer(
|
||||
LecternInventoryRequestPayload.ID,
|
||||
LecternInventoryRequestPayload.CODEC,
|
||||
((payload, context) -> BookshelfInspector.networkHandlers.lecternInventoryRequestServerPayloadHandler.receive(payload, (ServerPlayer) context.player()))
|
||||
);
|
||||
registrar.playToClient(
|
||||
BookShelfInventoryPayload.ID,
|
||||
BookShelfInventoryPayload.CODEC,
|
||||
@@ -35,6 +25,16 @@ public class NetworkHandler {
|
||||
ModCheckPayload.CODEC,
|
||||
((payload, context) -> BookshelfInspector.networkHandlers.modServerPayloadHandler.receive(payload, (LocalPlayer) context.player()))
|
||||
);
|
||||
registrar.playToServer(
|
||||
BookShelfInventoryRequestPayload.ID,
|
||||
BookShelfInventoryRequestPayload.CODEC,
|
||||
((payload, context) -> BookshelfInspector.networkHandlers.bookShelfInventoryRequestServerPayloadHandler.receive(payload, (ServerPlayer) context.player()))
|
||||
);
|
||||
registrar.playToServer(
|
||||
LecternInventoryRequestPayload.ID,
|
||||
LecternInventoryRequestPayload.CODEC,
|
||||
((payload, context) -> BookshelfInspector.networkHandlers.lecternInventoryRequestServerPayloadHandler.receive(payload, (ServerPlayer) context.player()))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
modLoader = "javafml" #mandatory
|
||||
loaderVersion = "${neoforge_loader_version_range}" #mandatory
|
||||
loaderVersion = "*" #mandatory
|
||||
license = "${license}" # Review your options at https://choosealicense.com/.
|
||||
#issueTrackerURL="https://change.me.to.your.issue.tracker.example.invalid/" #optional
|
||||
[[mods]] #mandatory
|
||||
@@ -12,6 +12,7 @@ logoFile="${mod_id}.png" #optional
|
||||
credits="${credits}" #optional
|
||||
authors = "${mod_author}" #optional
|
||||
description = '''${description}''' #mandatory (Supports multiline text)
|
||||
displayTest = "NONE"
|
||||
[[mixins]]
|
||||
config = "${mod_id}.mixins.json"
|
||||
[[dependencies.${mod_id}]] #optional
|
||||
|
||||
Reference in New Issue
Block a user