Class SimpleRadioApi

java.lang.Object
com.codinglitch.simpleradio.SimpleRadioApi
Direct Known Subclasses:
ClientSimpleRadioApi, ServerSimpleRadioApi

public abstract class SimpleRadioApi extends Object
  • Constructor Details

    • SimpleRadioApi

      public SimpleRadioApi()
  • Method Details

    • getInstance

      public static SimpleRadioApi getInstance()
    • getInstance

      public static SimpleRadioApi getInstance(boolean isClient)
    • frequencies

      public abstract Frequencies frequencies()
    • getConfig

      public abstract <T> Optional<T> getConfig(String path)
      Gets a config entry from a specified path

      To get the soundListening entry from the router config:

      ServerSimpleRadioApi.getInstance().getConfig("router.soundListening");
      Parameters:
      path - The path to the config entry
      Returns:
      An optional containing the value, if found
    • setConfig

      public abstract <T> void setConfig(String path, T value)
      Sets a config entry from a specified path

      To set the soundListening entry from the router config:

      ServerSimpleRadioApi.getInstance().getConfig("router.soundListening", true);
      Parameters:
      path - The path to the config entry
      value - The value to set the config entry to
    • listen

      public abstract <E extends SimpleRadioEvent> void listen(Class<E> event, Consumer<E> listener)
    • travelExtension

      public abstract net.minecraft.core.BlockPos travelExtension(net.minecraft.core.BlockPos pos, net.minecraft.world.level.LevelAccessor level)
    • registerRouter

      public abstract <R extends Router> void registerRouter(R router)
    • registerRouter

      public abstract <R extends Router> void registerRouter(R router, @Nullable @Nullable Frequency frequency)
    • newRouter

      public abstract Router newRouter(UUID reference)
      Creates a blank Router with the specified reference.
      Parameters:
      reference - The reference. If you are creating a block entity with a router, this should be equivalent to a UUID you store and save.
      Returns:
      The created router.
    • newRouter

      public abstract Router newRouter(WorldlyPosition position)
      Creates a blank Router at the specified location with a random UUID. Most of the time, you should instead use newRouter(UUID) or newRouter(UUID, WorldlyPosition).
      Parameters:
      position - The location of the router.
      Returns:
      The created router
    • newRouter

      public abstract Router newRouter(UUID reference, WorldlyPosition position)
      Creates a blank Router at the specified location with the specified reference.
      Parameters:
      reference - The reference. If you are creating a block entity with a router, this should be equivalent to a UUID you store and save.
      position - The location of the router.
      Returns:
      The created router
    • newSource

      public abstract Source newSource(UUID owner, WorldlyPosition location, byte[] data, float volume)
    • info

      public abstract void info(Object object, Object... substitutions)
    • debug

      public abstract void debug(Object object, Object... substitutions)
    • warn

      public abstract void warn(Object object, Object... substitutions)
    • error

      public abstract void error(Object object, Object... substitutions)
    • getRouterSided

      public static Router getRouterSided(UUID reference, boolean isClient)
    • getRouterSided

      public static Router getRouterSided(UUID reference, @Nullable @Nullable String type, boolean isClient)
    • registerRouterSided

      public static void registerRouterSided(Router router, boolean isClient, @Nullable @Nullable Frequency frequency)
    • removeRouterSided

      public static Router removeRouterSided(UUID uuid, boolean isClient)
      Removes the given router from the global map given the indicated side. This will consequently make this router invalid.

      It should be noted that this does not remove it from the individual router maps (Listeners, Speakers, etc.)

      Parameters:
      uuid - The UUID of the router to remove.
      isClient - Whether or not to remove it from the client or server map.
      Returns:
      The router that was removed, if it exists.
    • removeRouterSided

      public static Router removeRouterSided(Router router, boolean isClient)
      Removes the given router from the global map given the indicated side. This will consequently make this router invalid.

      It should be noted that this does not remove it from the individual router maps (Listeners, Speakers, etc.)

      Parameters:
      router - The router to remove.
      isClient - Whether or not to remove it from the client or server map.
      Returns:
      The router that was removed, if it exists.
    • removeRouterSided

      public static Router removeRouterSided(WorldlyPosition position, boolean isClient)
      Removes the given router from the global map given the indicated side. This will consequently make this router invalid.

      It should be noted that this does not remove it from the individual router maps (Listeners, Speakers, etc.)

      Parameters:
      position - The position of the router to remove.
      isClient - Whether or not to remove it from the client or server map.
      Returns:
      The router that was removed, if it exists.