Class McUtils

java.lang.Object
com.shanebeestudios.nms.api.util.McUtils

public class McUtils extends Object
Utility class for changing Minecraft to/from Bukkit classes
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull net.minecraft.world.level.biome.BiomeResolver
    getBiomeResolver(org.apache.commons.lang3.mutable.MutableInt count, net.minecraft.world.level.chunk.ChunkAccess chunkAccess, net.minecraft.world.level.levelgen.structure.BoundingBox box, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, Predicate<net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome>> filter)
    Make a resolver for 3D shifted biomes
    static @NotNull BlockData
    getBlockDataFromState(net.minecraft.world.level.block.state.BlockState blockState)
    Get a Bukkit Blockdata from a Minecraft BlockState
    static @NotNull net.minecraft.world.level.block.state.BlockState
    Get a Minecraft BlockState from a Bukkit Block
    static @NotNull net.minecraft.world.level.block.state.BlockState
    Get a Minecraft BlockState from a Bukkit BlockData
    static @NotNull net.minecraft.core.Direction
    Convert Bukkit BlockFace to Minecraft Direction
    static net.minecraft.world.entity.EntityType<?>
    Get the NMS EntityType from Bukkit EntityType
    static <T> net.minecraft.core.Holder.Reference<T>
    getHolderReference(net.minecraft.core.Registry<T> registry, NamespacedKey key)
    Get a holder reference from a registry
    static net.minecraft.world.level.chunk.LevelChunk
    Get an instance of a LevelChunk from a BukkitChunk
    static @NotNull com.mojang.datafixers.util.Pair<net.minecraft.server.level.ServerLevel,net.minecraft.core.BlockPos>
    getLevelPos(@NotNull Location location)
    Get a Minecraft Level and BlockPos from a Bukkit Location
    static @NotNull Location
    getLocation(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.Level level)
    Get a Bukkit Location from a Minecraft BlockPos and Level
    static net.minecraft.server.dedicated.DedicatedServer
    Get the Minecraft Server
    static @NotNull NamespacedKey
    getNamespacedKey(net.minecraft.resources.ResourceLocation resourceLocation)
    Convert Minecraft ResourceLocation to Bukkit NamespacedKey
    static net.minecraft.world.entity.Entity
    getNMSEntity(Entity bukkitEntity)
    Get an NMS Entity from a Bukkit Entity
    static @NotNull net.minecraft.core.BlockPos
    getPos(@NotNull Location location)
    Get a Minecraft BlockPos from a Bukkit Location
    static <T> net.minecraft.core.Registry<T>
    getRegistry(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<? extends T>> registry)
    Get a Minecraft Registry
    static <T> @NotNull List<NamespacedKey>
    getRegistryKeys(net.minecraft.core.Registry<T> registry)
    Get all keys from a registry
    static <T> T
    getRegistryValue(net.minecraft.core.Registry<T> registry, NamespacedKey key)
    Get a keyed value from a registry
    static @NotNull net.minecraft.resources.ResourceLocation
    Convert a Bukkit NamespacedKey to Minecraft ResourceLocation
    static @NotNull net.minecraft.server.level.ServerLevel
    getServerLevel(@NotNull World world)
    Get an instance of ServerLevel from a Bukkit World
    static @NotNull net.minecraft.server.level.ServerPlayer
    getServerPlayer(@NotNull Player player)
    Get a Minecraft ServerPlayer from a Bukkit Player
    static @NotNull net.minecraft.world.phys.Vec3
    getVec3(Location location)
    Get a Minecraft Vec# from a Bukkit Location
    static @NotNull net.minecraft.world.level.WorldGenLevel
    getWorldGenLevel(@NotNull World world)
    Deprecated.
    Unused, use getServerLevel(World) instead
    static void
    setSkin(com.mojang.authlib.GameProfile gameProfile)
    Set the skin of a GameProfile

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getPos

      @NotNull public static @NotNull net.minecraft.core.BlockPos getPos(@NotNull @NotNull Location location)
      Get a Minecraft BlockPos from a Bukkit Location
      Parameters:
      location - Location to change to BlockPos
      Returns:
      BlockPos from Location
    • getVec3

      @NotNull public static @NotNull net.minecraft.world.phys.Vec3 getVec3(Location location)
      Get a Minecraft Vec# from a Bukkit Location
      Parameters:
      location - Location to convert to Vec3
      Returns:
      Vec3 from Location
    • getDirection

      @NotNull public static @NotNull net.minecraft.core.Direction getDirection(BlockFace blockFace)
      Convert Bukkit BlockFace to Minecraft Direction
      Parameters:
      blockFace - BlockFace to convert
      Returns:
      Minecraft Direction from BlockFace
    • getLevelPos

      @NotNull public static @NotNull com.mojang.datafixers.util.Pair<net.minecraft.server.level.ServerLevel,net.minecraft.core.BlockPos> getLevelPos(@NotNull @NotNull Location location)
      Get a Minecraft Level and BlockPos from a Bukkit Location
      Parameters:
      location - Location to get world and pos from
      Returns:
      Pair of Level and BlockPos
    • getLocation

      @NotNull public static @NotNull Location getLocation(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.Level level)
      Get a Bukkit Location from a Minecraft BlockPos and Level
      Parameters:
      blockPos - BlockPos to change to location
      level - Level to add to location
      Returns:
      Location from BlockPos/Level
    • getResourceLocation

      @NotNull public static @NotNull net.minecraft.resources.ResourceLocation getResourceLocation(NamespacedKey bukkitKey)
      Convert a Bukkit NamespacedKey to Minecraft ResourceLocation
      Parameters:
      bukkitKey - NamespacedKey to change to ResourceLocation
      Returns:
      ResourceLocation from NamespacedKey
    • getNamespacedKey

      @NotNull public static @NotNull NamespacedKey getNamespacedKey(net.minecraft.resources.ResourceLocation resourceLocation)
      Convert Minecraft ResourceLocation to Bukkit NamespacedKey
      Parameters:
      resourceLocation - ResourceLocation to change to NamespacedKey
      Returns:
      ResourceLocation from NamespacedKey
    • getServerLevel

      @NotNull public static @NotNull net.minecraft.server.level.ServerLevel getServerLevel(@NotNull @NotNull World world)
      Get an instance of ServerLevel from a Bukkit World
      Parameters:
      world - World to get ServerLevel from
      Returns:
      ServerLevel from World
    • getWorldGenLevel

      @NotNull @Deprecated public static @NotNull net.minecraft.world.level.WorldGenLevel getWorldGenLevel(@NotNull @NotNull World world)
      Deprecated.
      Unused, use getServerLevel(World) instead
      Get an instance of WorldGenLevel from a Bukkit World
      Parameters:
      world - Bukkit world to get WorldGenLevel from
      Returns:
      WorldGenLevel from Bukkit world
    • getLevelChunk

      public static net.minecraft.world.level.chunk.LevelChunk getLevelChunk(Chunk chunk)
      Get an instance of a LevelChunk from a BukkitChunk
      Parameters:
      chunk - Bukkit Chunk to convert
      Returns:
      LevelChunk from Chunk
    • getRegistry

      public static <T> net.minecraft.core.Registry<T> getRegistry(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<? extends T>> registry)
      Get a Minecraft Registry
      Type Parameters:
      T - ResourceKey
      Parameters:
      registry - ResourceKey of registry
      Returns:
      Registry from key
    • getServerPlayer

      @NotNull public static @NotNull net.minecraft.server.level.ServerPlayer getServerPlayer(@NotNull @NotNull Player player)
      Get a Minecraft ServerPlayer from a Bukkit Player
      Parameters:
      player - Bukkit player to convert to NMS player
      Returns:
      NMS player
    • getNMSEntity

      public static net.minecraft.world.entity.Entity getNMSEntity(Entity bukkitEntity)
      Get an NMS Entity from a Bukkit Entity
      Parameters:
      bukkitEntity - Bukkit Entity
      Returns:
      NMS Entity
    • getEntityType

      public static net.minecraft.world.entity.EntityType<?> getEntityType(EntityType bukkitType)
      Get the NMS EntityType from Bukkit EntityType
      Parameters:
      bukkitType - Bukkit EntityType to convert
      Returns:
      NMS EntityType from Bukkit
    • getBlockDataFromState

      @NotNull public static @NotNull BlockData getBlockDataFromState(net.minecraft.world.level.block.state.BlockState blockState)
      Get a Bukkit Blockdata from a Minecraft BlockState
      Parameters:
      blockState - BlockState to convert
      Returns:
      BlockData from state
    • getBlockStateFromBlock

      @NotNull public static @NotNull net.minecraft.world.level.block.state.BlockState getBlockStateFromBlock(Block bukkitBlock)
      Get a Minecraft BlockState from a Bukkit Block
      Parameters:
      bukkitBlock - Bukkit Block to grab state from
      Returns:
      BlockState from Bukkit Block
    • getBlockStateFromData

      @NotNull public static @NotNull net.minecraft.world.level.block.state.BlockState getBlockStateFromData(BlockData blockData)
      Get a Minecraft BlockState from a Bukkit BlockData
      Parameters:
      blockData - BlockData to convert
      Returns:
      Converted BlockState
    • getHolderReference

      @Nullable public static <T> net.minecraft.core.Holder.Reference<T> getHolderReference(net.minecraft.core.Registry<T> registry, NamespacedKey key)
      Get a holder reference from a registry
      Type Parameters:
      T - Class type of registry
      Parameters:
      registry - Registry to grab holder from
      key - Key of holder
      Returns:
      Holder from registry
    • getRegistryValue

      @Nullable public static <T> T getRegistryValue(net.minecraft.core.Registry<T> registry, NamespacedKey key)
      Get a keyed value from a registry
      Type Parameters:
      T - Registry class type
      Parameters:
      registry - Registry to grab value from
      key - Key of value to grab
      Returns:
      Value from registry
    • getRegistryKeys

      @NotNull public static <T> @NotNull List<NamespacedKey> getRegistryKeys(net.minecraft.core.Registry<T> registry)
      Get all keys from a registry
      Type Parameters:
      T - Registry class type
      Parameters:
      registry - Registry to grab keys from
      Returns:
      List of NamespacedKeys for all keys in registry
    • getBiomeResolver

      @NotNull public static @NotNull net.minecraft.world.level.biome.BiomeResolver getBiomeResolver(org.apache.commons.lang3.mutable.MutableInt count, net.minecraft.world.level.chunk.ChunkAccess chunkAccess, net.minecraft.world.level.levelgen.structure.BoundingBox box, net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biome, Predicate<net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome>> filter)
      Make a resolver for 3D shifted biomes
      Parameters:
      count - counter
      chunkAccess - Chunk where biome is
      box - BoundingBox for biome change
      biome - Biome
      filter - Filter
      Returns:
      Biome resolver
    • setSkin

      public static void setSkin(com.mojang.authlib.GameProfile gameProfile)
      Set the skin of a GameProfile
      Parameters:
      gameProfile - Profile to set
    • getMinecraftServer

      public static net.minecraft.server.dedicated.DedicatedServer getMinecraftServer(Server server)
      Get the Minecraft Server
      Parameters:
      server - Bukkit Server to convert to Minecraft Server
      Returns:
      Minecraft Server from Bukkit Server