Skip to content

Commit

Permalink
Add more APIs for MinecraftClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffreyg1228 authored Feb 7, 2024
1 parent 2d54452 commit fbdf54e
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package cn.zbx1425.mtrsteamloco.render.scripting.util;

import cn.zbx1425.sowcer.math.Vector3f;
import com.mojang.text2speech.Narrator;
import mtr.mappings.Text;
import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.player.Player;

public class MinecraftClientUtil {

Expand All @@ -19,4 +22,15 @@ public static int worldDayTime() {
return Minecraft.getInstance().level != null
? (int) Minecraft.getInstance().level.getDayTime() : 0;
}

public static void narrate(String message) {
Narrator.getNarrator().say(message, true);
}

public static void displayMessage(String message, boolean actionBar) {
final Player player = Minecraft.getInstance().player;
if (player != null) {
player.displayClientMessage(Text.literal(message), actionBar);
}
}
}

0 comments on commit fbdf54e

Please sign in to comment.