Advertisement
Guest User

CommonProxy

a guest
Oct 23rd, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. class CommonProxy {
  2. public CommonProxy() {
  3. // Life-cycle events
  4. final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
  5. modEventBus.addListener(CommonProxy::commonSetup);
  6.  
  7. // Other events
  8. MinecraftForge.EVENT_BUS.register(this);
  9. }
  10.  
  11. private static void commonSetup(FMLCommonSetupEvent event) {
  12. DeferredWorkQueue.runLater(() -> {
  13. CapabilityManager.INSTANCE.register(IModTag.class, new ModTagStorage(), ModTagProvider::new);
  14. });
  15. }
  16.  
  17. static class ClientProxy extends CommonProxy {
  18. ClientProxy() {
  19. final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
  20. modEventBus.addListener(ClientProxy::clientSetup);
  21. modEventBus.addListener(ModEvents::registerItemColor);
  22. }
  23.  
  24. private static void clientSetup(FMLClientSetupEvent event) { }
  25. }
  26.  
  27. static class ServerProxy extends CommonProxy {
  28. ServerProxy() {
  29. final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
  30. modEventBus.addListener(ServerProxy::serverSetup);
  31. }
  32.  
  33. private static void serverSetup(FMLDedicatedServerSetupEvent event) { }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement