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 voidblitLargeTexture(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 voidblitLargeTexture(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 voidblitSmallTexture(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 voidblitSmallTexture(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 voidblitTexture(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.resources.Identifier sprite, int x, int y, int width, int height) Blits a texture.static voidblitTexture(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.static UpdatableSpriteButtoncreateMenuButton(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.static UpdatableSpriteButtoncreateMenuButton(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 voiddisconnect(Runnable runnable) Disconnects from the current world with a consumer.static voiddrawLargeSprite(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 voiddrawLargeSprite(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 voiddrawModInfo(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 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 x, int y, int width, int height) Draws a sprite.static voiddrawSprite(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 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 booleanstatic voidopenDebugEntriesScreen(net.minecraft.client.gui.screens.Screen parentScreen, String text) Opens theDebugOptionsScreenwith set text for the search bar.static 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, UpdatableSpriteButton button) Renders the update icon on a button.static voidSets the currnet screen to null.static voidStops and closes the game with a consumer.static voidtryOpenConfigScreen(Supplier<net.minecraft.client.gui.screens.Screen> configScreen, net.minecraft.network.chat.Component yourModName, ModConfigLib lib) Tries to open aconfigurationscreen, if the config library mod is installed, and warns the user if it's not.static voidtryOpenYaclScreen(Supplier<net.minecraft.client.gui.screens.Screen> configScreen, net.minecraft.network.chat.Component yourModName) Tries to open aYetAnotherConfigLibscreen, and warns the user if it's not.
-
Constructor Details
-
ClientTasks
public ClientTasks()
-
-
Method Details
-
stop
Stops and closes the game with a consumer. -
disconnect
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 aYetAnotherConfigLibscreen, 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 aconfigurationscreen, 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 theDebugOptionsScreenwith 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 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.
-