Class PlayerUtil

java.lang.Object
my.celium.org.util.PlayerUtil

public final class PlayerUtil extends Object
Small cohesive player helpers. Server-side unless noted.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    countItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item)
     
    static net.minecraft.world.phys.Vec3
    getLookDirection(net.minecraft.world.entity.player.Player player)
    Unit look direction vector.
    static void
    giveItem(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack stack)
    Gives stack to the player; whatever does not fit is dropped at their feet.
    static boolean
    hasItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item, int amount)
     
    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).
    static int
    removeItem(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.Item item, int amount)
     
    static void
    sendActionBar(net.minecraft.server.level.ServerPlayer player, net.minecraft.network.chat.Component message)
     
    static void
    sendMessage(net.minecraft.world.entity.player.Player player, net.minecraft.network.chat.Component message)
     
    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.
    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).
    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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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)
      Gives stack to 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 see teleportToLevel(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.