Class McHelper

java.lang.Object
me.tamkungz.nilkit.helper.McHelper

public final class McHelper extends Object
McHelper — utility methods for interacting with Minecraft instance, players, and world data. Works with SimpleRemap to simplify obfuscated access.
  • Method Details

    • getMinecraft

      public static Object getMinecraft(SimpleRemap remap) throws Exception
      Returns the Minecraft instance without linking NilKit to a specific Minecraft class at class-load time. The target class is resolved only when this helper is explicitly called.
      Throws:
      Exception
    • getMinecraftSafe

      public static Object getMinecraftSafe(SimpleRemap remap)
      Safe version of getMinecraft (returns null on failure).
    • isMinecraftPresent

      public static boolean isMinecraftPresent(SimpleRemap remap)
      Returns true when the mapped Minecraft client class can be resolved.
    • getLocalPlayer

      public static Object getLocalPlayer(Object mc, SimpleRemap remap)
      Returns the local player instance.
    • getPlayerName

      public static String getPlayerName(Object player, SimpleRemap remap)
      Returns the player name using multiple fallback methods.
    • isCreative

      public static boolean isCreative(Object player, SimpleRemap remap)
      Returns true if the player is in creative mode.
    • isSurvivalLike

      public static boolean isSurvivalLike(Object player, SimpleRemap remap)
      Returns true if the player is not in creative mode.
    • getHeldItemStack

      public static Object getHeldItemStack(Object player, SimpleRemap remap)
    • getItemFromStack

      public static Object getItemFromStack(Object stack, SimpleRemap remap)
    • getItemId

      public static int getItemId(Object item, SimpleRemap remap)
    • getHeldItemId

      public static int getHeldItemId(Object player, SimpleRemap remap)
    • getFoodStats

      public static Object getFoodStats(Object player, SimpleRemap remap)
      Returns FoodStats instance with fallbacks.
    • addFoodStats

      public static void addFoodStats(Object player, int hunger, float saturation, SimpleRemap remap)
      Adds food stats to the player.
    • getStackSize

      public static int getStackSize(Object stack, SimpleRemap remap)
    • setStackSize

      public static void setStackSize(Object stack, int size, SimpleRemap remap) throws Exception
      Throws:
      Exception
    • writeHeldStack

      public static void writeHeldStack(Object player, Object stack, SimpleRemap remap)
      Writes the held item stack into the player's inventory.
    • clearHeldStack

      public static void clearHeldStack(Object player, SimpleRemap remap)
    • getIntegratedServer

      public static Object getIntegratedServer(Object mc)
      Returns integrated server instance if present.
    • isHost

      public static boolean isHost(Object mc)
    • getServerConfigManager

      public static Object getServerConfigManager(Object mc, SimpleRemap remap)
    • getServerPlayerList

      public static List<Object> getServerPlayerList(Object mc, SimpleRemap remap)
    • getServerPlayerByName

      public static Object getServerPlayerByName(Object mc, String name, SimpleRemap remap)
    • getEntityPos

      public static double[] getEntityPos(Object entity)
      Returns entity position as [x, y, z], or null if unavailable.
    • getLookVec

      public static double[] getLookVec(Object entity, SimpleRemap remap)
      Returns normalized look vector.
    • extractVec3

      public static double[] extractVec3(Object vec, SimpleRemap remap) throws Exception
      Throws:
      Exception
    • getWorldFromEntity

      public static Object getWorldFromEntity(Object entity, SimpleRemap remap)
      Returns world object from an entity.
    • collectPlayers

      public static List<Object> collectPlayers(Object world, Object exclude, SimpleRemap remap)
      Collects all player-like entities in the world (excluding given object).
    • playSound

      public static void playSound(Object player, String sound, float volume, float pitch, SimpleRemap remap)