Class Compatibility
java.lang.Object
com.minecolonies.api.compatibility.Compatibility
This class is to store the methods that call the methods to check for miscellaneous compatibility problems.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic IBeehiveCompatstatic DynamicTreeProxystatic IJeiProxystatic TinkersToolProxystatic SlimeTreeProxy -
Method Summary
Modifier and TypeMethodDescriptionstatic doublegetAttackDamage(@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 positionstatic 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 Liststatic RunnablegetDynamicTreeBreakAction(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 treestatic net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType>Returns the damageType string falling dynamic Tree's usestatic intgetItemLevel(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.TiergetItemTier(net.minecraft.world.item.ItemStack stack) Return the Tier associated with this stack.static intgetLeafVariant(@NotNull net.minecraft.world.level.block.state.BlockState leaf) Get the Slime leaf variant.static booleangetMiningLevelCompatibility(@Nullable net.minecraft.world.item.ItemStack stack, @Nullable String tool) This method checks to see if STACK is able to mine anything.static intgetToolLevel(@NotNull net.minecraft.world.item.ItemStack stack) Calculate the tool level of the stack.static booleanisCustomWeapon(net.minecraft.world.item.ItemStack stack) Query all registered weapon recognizers.static booleanisDynamicBlock(net.minecraft.world.level.block.Block block) Check if block is a Dynamic treestatic booleanisDynamicFamilyFitting(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 familystatic booleanisDynamicLeaf(net.minecraft.world.level.block.Block block) Check if block is a Dynamic Leafstatic booleanisDynamicTreeSapling(net.minecraft.world.item.Item item) Check wether the item is a dynamic Saplingstatic booleanisDynamicTreeSapling(net.minecraft.world.item.ItemStack stack) Check wether the Itemstack is a dynamic Saplingstatic booleanisDynamicTrunkShell(net.minecraft.world.level.block.Block block) Check whether the block is a shell block.static booleanCheck if dynamic tree's is presentstatic booleanisSlimeBlock(@NotNull net.minecraft.world.level.block.Block block) This method checks if block is slime block.static booleanisSlimeDirtOrGrass(@NotNull net.minecraft.world.level.block.Block block) This method checks if block is slime dirt.static booleanisSlimeLeaf(@NotNull net.minecraft.world.level.block.Block block) This method checks if block is slime leaf.static booleanisSlimeSapling(@NotNull net.minecraft.world.level.block.Block block) This method checks if block is slime sapling.static booleanisTinkersTool(@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 booleanisTinkersWeapon(@NotNull net.minecraft.world.item.ItemStack stack) Check if a certain itemstack is a tinkers weapon.static booleanplantDynamicSapling(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 locationstatic voidregisterItemTier(@NotNull net.minecraft.world.item.Item item, int level) Register an item by level only.static voidregisterItemTier(@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 voidregisterItemTierIfAbsent(@NotNull net.minecraft.world.item.Item item, int level) Register an item by level only if not already registered.static voidregisterItemTierIfAbsent(@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 voidregisterWeaponRecognizer(Predicate<net.minecraft.world.item.ItemStack> recognizer) Register a custom weapon recognizer.
-
Field Details
-
jeiProxy
-
beeHiveCompat
-
tinkersSlimeCompat
-
tinkersCompat
-
dynamicTreesCompat
-
-
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 vanillaTiersinstance is stored so thatgetItemTier(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 vanillaTiersinstance 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. Returnsnullonly when the item has not been registered. Items registered without a real Tier (armor, bow, etc.) return the closest matching vanillaTiersinstance.- 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.
-
getDynamicTreeDamage
public static net.minecraft.resources.ResourceKey<net.minecraft.world.damagesource.DamageType> getDynamicTreeDamage()Returns the damageType string falling dynamic Tree's use- Returns:
- damageType
-
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 inpos- position of the LeafblockState- Blockstate of the Leaffortune- amount of fortune to useleaf- 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 inlocation- location to plant the saplingsapling- 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 inblockToBreak- The block of the dynamic treetoolToUse- The tool to break the tree with, optionalworkerPos- The position the fakeplayer breaks the tree from, optional- Returns:
- Runnable to break the Tree
-
isDynamicTreeSapling
public static boolean isDynamicTreeSapling(net.minecraft.world.item.Item item) Check wether the item is a dynamic Sapling- Parameters:
item- Item to check- Returns:
- true if so.
-
isDynamicTreeSapling
public static boolean isDynamicTreeSapling(net.minecraft.world.item.ItemStack stack) Check wether 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 compareblock2- Second blockpos to compareworld- 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 posworld- worldamount- comb amount- Returns:
- list of drops
-