Class ModBase<T extends ModBase<T>>

java.lang.Object
org.cyclops.cyclopscore.helper.ModBaseCommon<T>
org.cyclops.cyclopscore.init.ModBase<T>
All Implemented Interfaces:
org.cyclops.cyclopscore.init.IModBase
Direct Known Subclasses:
ModBaseVersionable

public abstract class ModBase<T extends ModBase<T>> extends org.cyclops.cyclopscore.helper.ModBaseCommon<T>
Base class for mods which adds a few convenience methods.
  • Field Details

  • Constructor Details

    • ModBase

      public ModBase(String modId, Consumer<T> instanceSetter, net.neoforged.bus.api.IEventBus modEventBus)
  • Method Details

    • getModId

      public String getModId()
      Specified by:
      getModId in interface org.cyclops.cyclopscore.init.IModBase
      Overrides:
      getModId in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • getModHelpers

      public IModHelpersNeoForge getModHelpers()
    • getLoggerHelper

      public org.cyclops.cyclopscore.helper.LoggerHelper getLoggerHelper()
      Specified by:
      getLoggerHelper in interface org.cyclops.cyclopscore.init.IModBase
      Overrides:
      getLoggerHelper in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • getProxy

      public ICommonProxy getProxy()
    • getConfigHandler

      public ConfigHandler getConfigHandler()
    • getGenericReference

      public Map<ModBase.EnumReferenceKey<?>,Object> getGenericReference()
    • getWorldStorages

      public List<WorldStorage> getWorldStorages()
    • getKeyRegistry

      public IKeyRegistry getKeyRegistry()
    • getPacketHandler

      @Deprecated public PacketHandler getPacketHandler()
      Deprecated.
    • getPacketHandlerCommon

      public org.cyclops.cyclopscore.network.IPacketHandler getPacketHandlerCommon()
    • getCapabilityConstructorRegistry

      public CapabilityConstructorRegistry getCapabilityConstructorRegistry()
    • getImcHandler

      public IMCHandler getImcHandler()
    • getModName

      public String getModName()
    • getModEventBus

      public net.neoforged.bus.api.IEventBus getModEventBus()
    • getContainer

      public net.neoforged.fml.ModContainer getContainer()
      Returns:
      The mod container of this mod.
    • constructLoggerHelper

      protected org.cyclops.cyclopscore.helper.LoggerHelper constructLoggerHelper()
      Overrides:
      constructLoggerHelper in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • constructConfigHandler

      protected org.cyclops.cyclopscore.config.ConfigHandlerCommon constructConfigHandler()
    • constructPacketHandler

      protected PacketHandler constructPacketHandler()
    • constructCapabilityConstructorRegistry

      protected CapabilityConstructorRegistry constructCapabilityConstructorRegistry()
    • constructIMCHandler

      protected IMCHandler constructIMCHandler()
    • constructBaseCommand

      protected com.mojang.brigadier.builder.LiteralArgumentBuilder<net.minecraft.commands.CommandSourceStack> constructBaseCommand(net.minecraft.commands.Commands.CommandSelection selection, net.minecraft.commands.CommandBuildContext context)
      Overrides:
      constructBaseCommand in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • putGenericReference

      public <T> void putGenericReference(ModBase.EnumReferenceKey<T> key, T value)
      Save a mod value.
      Type Parameters:
      T - The value type.
      Parameters:
      key - The key.
      value - The value.
    • loadModCompats

      protected void loadModCompats(org.cyclops.cyclopscore.modcompat.ModCompatLoader modCompatLoader)
      This is called only once to let the mod compatibilities register themselves.
      Overrides:
      loadModCompats in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
      Parameters:
      modCompatLoader - The loader.
    • getReferenceValue

      public <T> T getReferenceValue(ModBase.EnumReferenceKey<T> key)
      Get the value for a generic reference key. The default keys can be found in ModBase.
      Type Parameters:
      T - The type of value.
      Parameters:
      key - The key of a value.
      Returns:
      The value for the given key.
    • log

      public void log(String message)
      Log a new info message for this mod.
      Parameters:
      message - The message to show.
    • log

      public void log(org.apache.logging.log4j.Level level, String message)
      Log a new message of the given level for this mod.
      Parameters:
      level - The level in which the message must be shown.
      message - The message to show.
    • setup

      protected void setup(net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent event)
      Called on the Forge setup lifecycle event.
      Parameters:
      event - The setup event.
    • setupClient

      protected void setupClient(net.neoforged.fml.event.lifecycle.FMLClientSetupEvent event)
      Called on the Forge client setup lifecycle event.
      Parameters:
      event - The setup event.
    • onRegisterKeyMappings

      protected void onRegisterKeyMappings(net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent event)
    • onServerStarting

      protected void onServerStarting(net.neoforged.neoforge.event.server.ServerStartingEvent event)
      Register the things that are related to when the server is starting.
      Parameters:
      event - The Forge server starting event.
    • onRegisterCommands

      protected void onRegisterCommands(net.neoforged.neoforge.event.RegisterCommandsEvent event)
    • onServerAboutToStart

      protected void onServerAboutToStart(net.neoforged.neoforge.event.server.ServerAboutToStartEvent event)
      Register the things that are related to when the server is about to start.
      Parameters:
      event - The Forge server about to start event.
    • onServerStarted

      protected void onServerStarted(net.neoforged.neoforge.event.server.ServerStartedEvent event)
      Register the things that are related to server starting.
      Parameters:
      event - The Forge server started event.
    • onServerStopping

      protected void onServerStopping(net.neoforged.neoforge.event.server.ServerStoppingEvent event)
      Register the things that are related to server stopping, like persistent storage.
      Parameters:
      event - The Forge server stopping event.
    • registerWorldStorage

      public void registerWorldStorage(WorldStorage worldStorage)
      Register a new world storage type. Make sure to call this at least before the event ServerStartedEvent is called.
      Parameters:
      worldStorage - The world storage to register.
    • constructClientProxy

      protected abstract IClientProxy constructClientProxy()
      Specified by:
      constructClientProxy in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • constructCommonProxy

      protected abstract ICommonProxy constructCommonProxy()
      Specified by:
      constructCommonProxy in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • onConfigsRegister

      protected void onConfigsRegister(org.cyclops.cyclopscore.config.ConfigHandlerCommon configHandler)
      Called when the configs should be registered.
      Overrides:
      onConfigsRegister in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
      Parameters:
      configHandler - The config handler to register to.
    • onConfigsRegister

      @Deprecated protected void onConfigsRegister(ConfigHandler configHandler)
      Deprecated.
    • toString

      public String toString()
      Overrides:
      toString in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class org.cyclops.cyclopscore.helper.ModBaseCommon<T extends ModBase<T>>
    • get

      @Nullable public static ModBase get(String modId)
      Get the mod by id.
      Parameters:
      modId - The mod id.
      Returns:
      The mod instance or null.
    • getMods

      public static Map<String,ModBase<?>> getMods()