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
    disconnect(Runnable runnable)
    Disconnects from the current world with a runnable.
    static void
    drawLargeSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, net.minecraft.client.gui.components.Button button)
    Draws a larger 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 larger sprite over a button with a custom alpha.
    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 xOffset, int yOffset, int width, int height)
    Draws a sprite.
    static void
    drawSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int xOffset, int yOffset, int width, int height, float f)
    Draws a sprite with a custom alpha value.
    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 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, net.minecraft.client.gui.components.SpriteIconButton button, boolean hasUpdate)
    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 runnable.

    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 runnable.
    • disconnect

      public static void disconnect(Runnable runnable)
      Disconnects from the current world with a runnable.
    • 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.
    • drawSprite

      public static void drawSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int xOffset, int yOffset, int width, int height)
      Draws a sprite.
    • 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 larger 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 larger 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 xOffset, int yOffset, int width, int height, float f)
      Draws a sprite with a custom alpha value.
    • drawUpdateSprite

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

      public static void renderUpdateIconOnButton(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.components.SpriteIconButton button, boolean hasUpdate)
      Renders the update icon on a button.
    • openLink

      public static void openLink(net.minecraft.client.gui.screens.Screen screen, String link, boolean trusted)
      Opens a link.
    • 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.