Class Compatibility

java.lang.Object
com.minecolonies.api.compatibility.Compatibility

public final class Compatibility extends Object
This class is to store the methods that call the methods to check for miscellaneous compatibility problems.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
     
    static IJeiProxy
     
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    getAttackDamage(@NotNull net.minecraft.world.item.ItemStack stack)
    Calculate the actual attack damage of the tinkers weapon.
    static List<net.minecraft.world.item.ItemStack>
    getCombsFromHive(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level world, int amount)
    Get comps from a hive at the given position
    static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>
    getDropsForDynamicLeaf(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState blockState, int fortune, net.minecraft.world.level.block.Block leaf)
    Returns drops of a dynamic seed as List
    static Runnable
    getDynamicTreeBreakAction(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockToBreak, net.minecraft.world.item.ItemStack toolToUse, net.minecraft.core.BlockPos workerPos)
    Creates a runnable to harvest/break a dynamic tree
    static int
    getItemLevel(net.minecraft.world.item.ItemStack stack)
    Return the pre-computed equipment level for this stack, or -1 if not registered.
    static @Nullable net.minecraft.world.item.Tier
    getItemTier(net.minecraft.world.item.ItemStack stack)
    Return the Tier associated with this stack.
    static int
    getLeafVariant(@NotNull net.minecraft.world.level.block.state.BlockState leaf)
    Get the Slime leaf variant.
    static boolean
    getMiningLevelCompatibility(@Nullable net.minecraft.world.item.ItemStack stack, @Nullable String tool)
    This method checks to see if STACK is able to mine anything.
    static int
    getToolLevel(@NotNull net.minecraft.world.item.ItemStack stack)
    Calculate the tool level of the stack.
    static boolean
    isCustomWeapon(net.minecraft.world.item.ItemStack stack)
    Query all registered weapon recognizers.
    static boolean
    isDynamicBlock(net.minecraft.world.level.block.Block block)
    Check if block is a Dynamic tree
    static boolean
    isDynamicFamilyFitting(net.minecraft.core.BlockPos block1, net.minecraft.core.BlockPos block2, net.minecraft.world.level.LevelAccessor world)
    Method to check if two given blocks have the same Tree family
    static boolean
    isDynamicLeaf(net.minecraft.world.level.block.Block block)
    Check if block is a Dynamic Leaf
    static boolean
    isDynamicTreeSapling(net.minecraft.world.item.ItemStack stack)
    Check whether the Itemstack is a dynamic Sapling
    static boolean
    isDynamicTrunkShell(net.minecraft.world.level.block.Block block)
    Check whether the block is a shell block.
    static boolean
    Check if dynamic tree's is present
    static boolean
    isSlimeBlock(@NotNull net.minecraft.world.level.block.Block block)
    This method checks if block is slime block.
    static boolean
    isSlimeDirtOrGrass(@NotNull net.minecraft.world.level.block.Block block)
    This method checks if block is slime dirt.
    static boolean
    isSlimeLeaf(@NotNull net.minecraft.world.level.block.Block block)
    This method checks if block is slime leaf.
    static boolean
    isSlimeSapling(@NotNull net.minecraft.world.level.block.Block block)
    This method checks if block is slime sapling.
    static boolean
    isTinkersTool(@Nullable net.minecraft.world.item.ItemStack stack, EquipmentTypeEntry toolType)
    Check if a certain item stack is a tinkers tool of the given tool type.
    static boolean
    isTinkersWeapon(@NotNull net.minecraft.world.item.ItemStack stack)
    Check if a certain itemstack is a tinkers weapon.
    static boolean
    plantDynamicSapling(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos location, net.minecraft.world.item.ItemStack sapling)
    Tries to plant a sapling at the given location
    static void
    registerItemTier(@NotNull net.minecraft.world.item.Item item, int level)
    Register an item by level only.
    static void
    registerItemTier(@NotNull net.minecraft.world.item.Item item, @NotNull net.minecraft.world.item.Tier tier, int level)
    Register an item with an explicit Tier object and pre-computed level.
    static void
    registerItemTierIfAbsent(@NotNull net.minecraft.world.item.Item item, int level)
    Register an item by level only if not already registered.
    static void
    registerItemTierIfAbsent(@NotNull net.minecraft.world.item.Item item, @NotNull net.minecraft.world.item.Tier tier, int level)
    Register an item with an explicit Tier and level only if not already registered.
    static void
    registerWeaponRecognizer(Predicate<net.minecraft.world.item.ItemStack> recognizer)
    Register a custom weapon recognizer.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • registerItemTier

      public static void registerItemTier(@NotNull @NotNull net.minecraft.world.item.Item item, @NotNull @NotNull net.minecraft.world.item.Tier tier, int level)
      Register an item with an explicit Tier object and pre-computed level. Always overwrites any existing entry — intended for mod compat hooks.
      Parameters:
      item - the item to register.
      tier - the Tier object to associate.
      level - the equipment level integer.
    • registerItemTier

      public static void registerItemTier(@NotNull @NotNull net.minecraft.world.item.Item item, int level)
      Register an item by level only. The closest matching vanilla Tiers instance is stored so that getItemTier(net.minecraft.world.item.ItemStack) never returns null for a registered item. Always overwrites any existing entry — intended for mod compat hooks.
      Parameters:
      item - the item to register.
      level - the equipment level integer.
    • registerItemTierIfAbsent

      public static void registerItemTierIfAbsent(@NotNull @NotNull net.minecraft.world.item.Item item, @NotNull @NotNull net.minecraft.world.item.Tier tier, int level)
      Register an item with an explicit Tier and level only if not already registered. Used by auto-population so explicit mod registrations are never overwritten.
      Parameters:
      item - the item to register.
      tier - the Tier object to associate.
      level - the equipment level integer.
    • registerItemTierIfAbsent

      public static void registerItemTierIfAbsent(@NotNull @NotNull net.minecraft.world.item.Item item, int level)
      Register an item by level only if not already registered. The closest matching vanilla Tiers instance is stored. Used by auto-population so explicit mod registrations are never overwritten.
      Parameters:
      item - the item to register.
      level - the equipment level integer.
    • getItemTier

      @Nullable public static @Nullable net.minecraft.world.item.Tier getItemTier(net.minecraft.world.item.ItemStack stack)
      Return the Tier associated with this stack. Returns null only when the item has not been registered. Items registered without a real Tier (armor, bow, etc.) return the closest matching vanilla Tiers instance.
      Parameters:
      stack - the item stack.
      Returns:
      the registered Tier, or null if not registered.
    • getItemLevel

      public static int getItemLevel(net.minecraft.world.item.ItemStack stack)
      Return the pre-computed equipment level for this stack, or -1 if not registered.
      Parameters:
      stack - the item stack.
      Returns:
      the equipment level, or -1.
    • registerWeaponRecognizer

      public static void registerWeaponRecognizer(Predicate<net.minecraft.world.item.ItemStack> recognizer)
      Register a custom weapon recognizer. The predicate should return true if the stack is a weapon that should be treated as a sword by colonists (e.g. maces, javelins).
      Parameters:
      recognizer - the predicate to register.
    • isCustomWeapon

      public static boolean isCustomWeapon(net.minecraft.world.item.ItemStack stack)
      Query all registered weapon recognizers.
      Parameters:
      stack - the item stack.
      Returns:
      true if any recognizer claims the stack as a weapon.
    • getMiningLevelCompatibility

      public static boolean getMiningLevelCompatibility(@Nullable @Nullable net.minecraft.world.item.ItemStack stack, @Nullable @Nullable String tool)
      This method checks to see if STACK is able to mine anything. It goes through all compatibility checks.
      Parameters:
      stack - the item in question.
      tool - the name of the tool.
      Returns:
      boolean whether the stack can mine or not.
    • isSlimeBlock

      public static boolean isSlimeBlock(@NotNull @NotNull net.minecraft.world.level.block.Block block)
      This method checks if block is slime block.
      Parameters:
      block - the block.
      Returns:
      if the block is a slime block.
    • isSlimeLeaf

      public static boolean isSlimeLeaf(@NotNull @NotNull net.minecraft.world.level.block.Block block)
      This method checks if block is slime leaf.
      Parameters:
      block - the block.
      Returns:
      if the block is a slime leaf.
    • isSlimeSapling

      public static boolean isSlimeSapling(@NotNull @NotNull net.minecraft.world.level.block.Block block)
      This method checks if block is slime sapling.
      Parameters:
      block - the block.
      Returns:
      if the block is a slime sapling.
    • isSlimeDirtOrGrass

      public static boolean isSlimeDirtOrGrass(@NotNull @NotNull net.minecraft.world.level.block.Block block)
      This method checks if block is slime dirt.
      Parameters:
      block - the block.
      Returns:
      if the block is slime dirt.
    • getLeafVariant

      public static int getLeafVariant(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState leaf)
      Get the Slime leaf variant.
      Parameters:
      leaf - the leaf.
      Returns:
      the variant.
    • isTinkersWeapon

      public static boolean isTinkersWeapon(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Check if a certain itemstack is a tinkers weapon.
      Parameters:
      stack - the stack to check for.
      Returns:
      true if so.
    • isTinkersTool

      public static boolean isTinkersTool(@Nullable @Nullable net.minecraft.world.item.ItemStack stack, EquipmentTypeEntry toolType)
      Check if a certain item stack is a tinkers tool of the given tool type.
      Parameters:
      stack - the stack to check for.
      toolType - the tool type.
      Returns:
      true if so.
    • getAttackDamage

      public static double getAttackDamage(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Calculate the actual attack damage of the tinkers weapon.
      Parameters:
      stack - the stack.
      Returns:
      the attack damage.
    • getToolLevel

      public static int getToolLevel(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Calculate the tool level of the stack.
      Parameters:
      stack - the stack.
      Returns:
      the tool level
    • isDynTreePresent

      public static boolean isDynTreePresent()
      Check if dynamic tree's is present
      Returns:
      the dynamic trees.
    • isDynamicBlock

      public static boolean isDynamicBlock(net.minecraft.world.level.block.Block block)
      Check if block is a Dynamic tree
      Parameters:
      block - the block to check.
      Returns:
      true if so.
    • isDynamicLeaf

      public static boolean isDynamicLeaf(net.minecraft.world.level.block.Block block)
      Check if block is a Dynamic Leaf
      Parameters:
      block - the block to check.
      Returns:
      true if so.
    • isDynamicTrunkShell

      public static boolean isDynamicTrunkShell(net.minecraft.world.level.block.Block block)
      Check whether the block is a shell block.
      Parameters:
      block - the block to check
      Returns:
      true if it is a shell block.
    • getDropsForDynamicLeaf

      public static net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getDropsForDynamicLeaf(net.minecraft.world.level.LevelAccessor world, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState blockState, int fortune, net.minecraft.world.level.block.Block leaf)
      Returns drops of a dynamic seed as List
      Parameters:
      world - world the Leaf is in
      pos - position of the Leaf
      blockState - Blockstate of the Leaf
      fortune - amount of fortune to use
      leaf - The leaf to check
      Returns:
      the list of drops
    • plantDynamicSapling

      public static boolean plantDynamicSapling(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos location, net.minecraft.world.item.ItemStack sapling)
      Tries to plant a sapling at the given location
      Parameters:
      world - World to plant the sapling in
      location - location to plant the sapling
      sapling - Itemstack of the sapling
      Returns:
      true if successful
    • getDynamicTreeBreakAction

      public static Runnable getDynamicTreeBreakAction(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos blockToBreak, net.minecraft.world.item.ItemStack toolToUse, net.minecraft.core.BlockPos workerPos)
      Creates a runnable to harvest/break a dynamic tree
      Parameters:
      world - The world the tree is in
      blockToBreak - The block of the dynamic tree
      toolToUse - The tool to break the tree with, optional
      workerPos - The position the fakeplayer breaks the tree from, optional
      Returns:
      Runnable to break the Tree
    • isDynamicTreeSapling

      public static boolean isDynamicTreeSapling(net.minecraft.world.item.ItemStack stack)
      Check whether the Itemstack is a dynamic Sapling
      Parameters:
      stack - Itemstack to check
      Returns:
      true if it is a dynamic Sapling
    • isDynamicFamilyFitting

      public static boolean isDynamicFamilyFitting(net.minecraft.core.BlockPos block1, net.minecraft.core.BlockPos block2, net.minecraft.world.level.LevelAccessor world)
      Method to check if two given blocks have the same Tree family
      Parameters:
      block1 - First blockpos to compare
      block2 - Second blockpos to compare
      world - the world to check.
      Returns:
      true when same family
    • getCombsFromHive

      public static List<net.minecraft.world.item.ItemStack> getCombsFromHive(net.minecraft.core.BlockPos pos, net.minecraft.world.level.Level world, int amount)
      Get comps from a hive at the given position
      Parameters:
      pos - TE pos
      world - world
      amount - comb amount
      Returns:
      list of drops