Class ClientTasks
java.lang.Object
net.dillon.dillonlib.task.ClientTasks
Client-side only methods and tasks that can be commonly used throughout your mod.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddisconnect(Runnable runnable) Disconnects from the current world with a runnable.static voiddrawLargeSprite(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 voiddrawLargeSprite(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 voiddrawSmallSprite(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 voiddrawSmallSprite(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 voiddrawSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int xOffset, int yOffset, int width, int height) Draws a sprite.static voiddrawSprite(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 voiddrawTooltip(net.minecraft.network.chat.Component text, net.minecraft.client.gui.GuiGraphicsExtractor context, int mouseX, int mouseY) Draws a tooltip.static voiddrawUpdateSprite(net.minecraft.client.gui.GuiGraphicsExtractor graphics, int x, int y) Draws the update icon.static voidexecuteIfClientLevel(Consumer<net.minecraft.client.multiplayer.ClientLevel> clientLevel) Executes a task of the currentClientLevelif it isn't null.static voidexecuteIfClientPlayer(Consumer<net.minecraft.client.player.LocalPlayer> localPlayer) Executes a task for theLocalPlayerif the player isn't null.static net.minecraft.client.gui.FontgetFont()static intgetGuiHeight(net.minecraft.client.gui.GuiGraphicsExtractor context) static intgetGuiWidth(net.minecraft.client.gui.GuiGraphicsExtractor context) static net.minecraft.client.Minecraftstatic net.minecraft.client.gui.screens.Screenstatic voidOpens a link.static voidopenScreen(net.minecraft.client.gui.screens.Screen screen) Opens a screen on the client.static voidplayLocalSound(net.minecraft.sounds.SoundEvent sound) Plays a sound to the client.static voidplayLocalSound(net.minecraft.sounds.SoundEvent sound, float volume, float pitch) Plays a sound to the client, with a custom volume and pitch.static voidplayLocalSoundToLocalPlayer(net.minecraft.sounds.SoundEvent sound) Plays a sound to theLocalPlayer.static voidplayLocalSoundToLocalPlayer(net.minecraft.sounds.SoundEvent sound, float volume, float pitch) Plays a sound to theLocalPlayer, with a custom volume and pitch.static voidrenderUpdateIconOnButton(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.gui.components.SpriteIconButton button, boolean hasUpdate) Renders the update icon on a button.static voidSets the currnet screen to null.static voidStops and closes the game with a runnable.
-
Constructor Details
-
ClientTasks
public ClientTasks()
-
-
Method Details
-
stop
Stops and closes the game with a runnable. -
disconnect
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 theLocalPlayer. -
playLocalSoundToLocalPlayer
public static void playLocalSoundToLocalPlayer(net.minecraft.sounds.SoundEvent sound, float volume, float pitch) Plays a sound to theLocalPlayer, 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 theLocalPlayerif the player isn't null. -
executeIfClientLevel
public static void executeIfClientLevel(Consumer<net.minecraft.client.multiplayer.ClientLevel> clientLevel) Executes a task of the currentClientLevelif it isn't null.
-