Class PlayerUtil
java.lang.Object
my.celium.org.util.PlayerUtil
Small cohesive player helpers. Server-side unless noted.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcountItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item) static net.minecraft.world.phys.Vec3getLookDirection(net.minecraft.world.entity.player.Player player) Unit look direction vector.static voidgiveItem(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack stack) Givesstackto the player; whatever does not fit is dropped at their feet.static booleanhasItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item, int amount) static voidplaySound(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.player.Player player, net.minecraft.sounds.SoundEvent event, net.minecraft.sounds.SoundSource source, float volume, float pitch) Plays a sound audible around the player (vanilla radius rules apply).static intremoveItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item, int amount) static voidsendActionBar(net.minecraft.server.level.ServerPlayer player, net.minecraft.network.chat.Component message) static voidsendMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component message) static voidteleport(net.minecraft.server.level.ServerPlayer player, double x, double y, double z, float yaw, float pitch) Teleports within the current dimension and syncs the client.static booleanteleportToLevel(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel target, double x, double y, double z, float yaw, float pitch) Teleports to another dimension (same dimension works too).static booleanteleportToLevel(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel target, net.minecraft.world.phys.Vec3 pos, float yaw, float pitch) Compatibility overload taking a position vector.
-
Method Details
-
sendMessage
public static void sendMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component message) -
sendActionBar
public static void sendActionBar(net.minecraft.server.level.ServerPlayer player, net.minecraft.network.chat.Component message) -
giveItem
public static void giveItem(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack stack) Givesstackto the player; whatever does not fit is dropped at their feet. The passed stack is consumed. -
hasItem
public static boolean hasItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item, int amount) -
countItem
public static int countItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item) -
removeItem
public static int removeItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item, int amount) -
getLookDirection
public static net.minecraft.world.phys.Vec3 getLookDirection(net.minecraft.world.entity.player.Player player) Unit look direction vector. -
playSound
public static void playSound(net.minecraft.server.level.ServerLevel level, net.minecraft.world.entity.player.Player player, net.minecraft.sounds.SoundEvent event, net.minecraft.sounds.SoundSource source, float volume, float pitch) Plays a sound audible around the player (vanilla radius rules apply). -
teleport
public static void teleport(net.minecraft.server.level.ServerPlayer player, double x, double y, double z, float yaw, float pitch) Teleports within the current dimension and syncs the client. For cross-dimension travel seeteleportToLevel(ServerPlayer, ServerLevel, double, double, double, float, float). -
teleportToLevel
public static boolean teleportToLevel(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel target, double x, double y, double z, float yaw, float pitch) Teleports to another dimension (same dimension works too).- Returns:
- whether the teleport succeeded
-
teleportToLevel
public static boolean teleportToLevel(net.minecraft.server.level.ServerPlayer player, net.minecraft.server.level.ServerLevel target, net.minecraft.world.phys.Vec3 pos, float yaw, float pitch) Compatibility overload taking a position vector.
-