Class ClientTasks

java.lang.Object
net.dillon.dillonlib.task.ClientTasks

public class ClientTasks extends Object
Client-side only methods and tasks that can be commonly used throughout your mod.
Since:
1.0
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    blitLargeTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
    Blits a large texture over a button.
    static void
    blitLargeTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
    Blits a large texture over a button with a custom alpha.
    static void
    blitSmallTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
    Blits a small texture over a button.
    static void
    blitSmallTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
    Blits a small texture over a button with a custom alpha.
    static void
    blitTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height)
    Blits a texture.
    static void
    blitTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height, float f)
    Blits a texture with a custom alpha value.
    createMenuButton(String name, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button.OnPress onPress, Map<Boolean, net.minecraft.network.chat.Component> update, net.minecraft.network.chat.Component tooltip, boolean withTooltip)
    Creates a menu button.
    createMenuButton(String name, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button.OnPress onPress, Map<Boolean, net.minecraft.network.chat.Component> update, net.minecraft.network.chat.Component tooltip, int spriteWidth, int spriteHeight, boolean withTooltip)
    Creates a menu button with a custom sprite width and height.
    static void
    disconnect(Runnable runnable)
    Disconnects from the current world with a consumer.
    static void
    drawLargeSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
    Draws a large sprite over a button.
    static void
    drawLargeSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
    Draws a large sprite over a button with a custom alpha.
    static void
    drawModInfo(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.screens.Screen menuScreen, net.minecraft.network.chat.Component version, net.minecraft.resources.Identifier logo, boolean hasUpdate)
    Draws a mod version and icon in a main menu screen.
    static void
    drawSmallSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
    Draws a small sprite over a button.
    static void
    drawSmallSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
    Draws a small sprite over a button with a custom alpha.
    static void
    drawSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height)
    Draws a sprite.
    static void
    drawSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height, float f)
    Draws a sprite with a custom alpha fade.
    static void
    drawTooltip(net.minecraft.network.chat.Component text, net.minecraft.client.gui.GuiGraphicsExtractor context, int mouseX, int mouseY)
    Draws a tooltip.
    static void
    drawUpdateSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y)
    Draws the update icon.
    static void
    executeIfClientLevel(Consumer<net.minecraft.client.multiplayer.ClientLevel> clientLevel)
    Executes a task of the current ClientLevel if it isn't null.
    static void
    executeIfClientPlayer(Consumer<net.minecraft.client.player.LocalPlayer> localPlayer)
    Executes a task for the LocalPlayer if the player isn't null.
    static net.minecraft.client.gui.Font
     
    static int
    getGuiHeight(net.minecraft.client.gui.GuiGraphicsExtractor context)
     
    static int
    getGuiWidth(net.minecraft.client.gui.GuiGraphicsExtractor context)
     
    static net.minecraft.client.Minecraft
     
    static net.minecraft.client.gui.screens.Screen
     
    static boolean
     
    static void
    openDebugEntriesScreen(net.minecraft.client.gui.screens.Screen parentScreen, String text)
    Opens the DebugOptionsScreen with set text for the search bar.
    static void
    openLink(net.minecraft.client.gui.screens.Screen screen, String link, boolean trusted)
    Opens a link.
    static void
    openScreen(net.minecraft.client.gui.screens.Screen screen)
    Opens a screen on the client.
    static void
    playLocalSound(net.minecraft.sounds.SoundEvent sound)
    Plays a sound to the client.
    static void
    playLocalSound(net.minecraft.sounds.SoundEvent sound, float volume, float pitch)
    Plays a sound to the client, with a custom volume and pitch.
    static void
    playLocalSoundToLocalPlayer(net.minecraft.sounds.SoundEvent sound)
    Plays a sound to the LocalPlayer.
    static void
    playLocalSoundToLocalPlayer(net.minecraft.sounds.SoundEvent sound, float volume, float pitch)
    Plays a sound to the LocalPlayer, with a custom volume and pitch.
    static void
    renderUpdateIconOnButton(net.minecraft.client.gui.GuiGraphicsExtractor graphics, UpdatableSpriteButton button)
    Renders the update icon on a button.
    static void
    Sets the currnet screen to null.
    static void
    stop(Runnable runnable)
    Stops and closes the game with a consumer.
    static void
    tryOpenConfigScreen(Supplier<net.minecraft.client.gui.screens.Screen> configScreen, net.minecraft.network.chat.Component yourModName, ModConfigLib lib)
    Tries to open a configuration screen, if the config library mod is installed, and warns the user if it's not.
    static void
    tryOpenYaclScreen(Supplier<net.minecraft.client.gui.screens.Screen> configScreen, net.minecraft.network.chat.Component yourModName)
    Tries to open a YetAnotherConfigLib screen, and warns the user if it's not.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ClientTasks

      public ClientTasks()
  • Method Details

    • stop

      public static void stop(Runnable runnable)
      Stops and closes the game with a consumer.
    • disconnect

      public static void disconnect(Runnable runnable)
      Disconnects from the current world with a consumer.
    • openScreen

      public static void openScreen(net.minecraft.client.gui.screens.Screen screen)
      Opens a screen on the client.
    • getScreen

      public static net.minecraft.client.gui.screens.Screen getScreen()
      Returns:
      the current Minecraft screen.
    • setNullScreen

      public static void setNullScreen()
      Sets the currnet screen to null.
    • getGuiWidth

      public static int getGuiWidth(net.minecraft.client.gui.GuiGraphicsExtractor context)
      Returns:
      the GUI width.
    • getGuiHeight

      public static int getGuiHeight(net.minecraft.client.gui.GuiGraphicsExtractor context)
      Returns:
      the GUI height.
    • getMinecraft

      public static net.minecraft.client.Minecraft getMinecraft()
      Returns:
      Minecraft's current instance.
    • getFont

      public static net.minecraft.client.gui.Font getFont()
      Returns:
      the Minecraft's font.
    • drawTooltip

      public static void drawTooltip(net.minecraft.network.chat.Component text, net.minecraft.client.gui.GuiGraphicsExtractor context, int mouseX, int mouseY)
      Draws a tooltip.
    • blitTexture

      public static void blitTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height)
      Blits a texture.
    • blitSmallTexture

      public static void blitSmallTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
      Blits a small texture over a button.
    • blitLargeTexture

      public static void blitLargeTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
      Blits a large texture over a button.
    • blitLargeTexture

      public static void blitLargeTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
      Blits a large texture over a button with a custom alpha.
    • blitSmallTexture

      public static void blitSmallTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
      Blits a small texture over a button with a custom alpha.
    • blitTexture

      public static void blitTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height, float f)
      Blits a texture with a custom alpha value.
    • drawSmallSprite

      public static void drawSmallSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
      Draws a small sprite over a button.
    • drawLargeSprite

      public static void drawLargeSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
      Draws a large sprite over a button.
    • drawLargeSprite

      public static void drawLargeSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
      Draws a large sprite over a button with a custom alpha.
    • drawSmallSprite

      public static void drawSmallSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button, float f)
      Draws a small sprite over a button with a custom alpha.
    • drawSprite

      public static void drawSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height)
      Draws a sprite.
    • drawSprite

      public static void drawSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height, float f)
      Draws a sprite with a custom alpha fade.
    • drawUpdateSprite

      public static void drawUpdateSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y)
      Draws the update icon.
    • drawModInfo

      public static void drawModInfo(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.screens.Screen menuScreen, net.minecraft.network.chat.Component version, net.minecraft.resources.Identifier logo, boolean hasUpdate)
      Draws a mod version and icon in a main menu screen.
    • tryOpenYaclScreen

      public static void tryOpenYaclScreen(Supplier<net.minecraft.client.gui.screens.Screen> configScreen, net.minecraft.network.chat.Component yourModName)
      Tries to open a YetAnotherConfigLib screen, and warns the user if it's not.
      See Also:
    • tryOpenConfigScreen

      public static void tryOpenConfigScreen(Supplier<net.minecraft.client.gui.screens.Screen> configScreen, net.minecraft.network.chat.Component yourModName, ModConfigLib lib)
      Tries to open a configuration screen, if the config library mod is installed, and warns the user if it's not.
      See Also:
    • openDebugEntriesScreen

      public static void openDebugEntriesScreen(net.minecraft.client.gui.screens.Screen parentScreen, String text)
      Opens the DebugOptionsScreen with set text for the search bar.
    • renderUpdateIconOnButton

      public static void renderUpdateIconOnButton(net.minecraft.client.gui.GuiGraphicsExtractor graphics, UpdatableSpriteButton button)
      Renders the update icon on a button.
    • createMenuButton

      public static UpdatableSpriteButton createMenuButton(String name, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button.OnPress onPress, Map<Boolean, net.minecraft.network.chat.Component> update, net.minecraft.network.chat.Component tooltip, boolean withTooltip)
      Creates a menu button.
    • createMenuButton

      public static UpdatableSpriteButton createMenuButton(String name, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button.OnPress onPress, Map<Boolean, net.minecraft.network.chat.Component> update, net.minecraft.network.chat.Component tooltip, int spriteWidth, int spriteHeight, boolean withTooltip)
      Creates a menu button with a custom sprite width and height.
    • openLink

      public static void openLink(net.minecraft.client.gui.screens.Screen screen, String link, boolean trusted)
      Opens a link.
    • isOnServer

      public static boolean isOnServer()
      Returns:
      if the current instance of Minecraft is on a server.
    • playLocalSoundToLocalPlayer

      public static void playLocalSoundToLocalPlayer(net.minecraft.sounds.SoundEvent sound)
      Plays a sound to the LocalPlayer.
    • playLocalSoundToLocalPlayer

      public static void playLocalSoundToLocalPlayer(net.minecraft.sounds.SoundEvent sound, float volume, float pitch)
      Plays a sound to the LocalPlayer, with a custom volume and pitch.
    • playLocalSound

      public static void playLocalSound(net.minecraft.sounds.SoundEvent sound)
      Plays a sound to the client.
    • playLocalSound

      public static void playLocalSound(net.minecraft.sounds.SoundEvent sound, float volume, float pitch)
      Plays a sound to the client, with a custom volume and pitch.
    • executeIfClientPlayer

      public static void executeIfClientPlayer(Consumer<net.minecraft.client.player.LocalPlayer> localPlayer)
      Executes a task for the LocalPlayer if the player isn't null.
    • executeIfClientLevel

      public static void executeIfClientLevel(Consumer<net.minecraft.client.multiplayer.ClientLevel> clientLevel)
      Executes a task of the current ClientLevel if it isn't null.