Class CompatibilityManager

java.lang.Object
com.minecolonies.api.compatibility.CompatibilityManager
All Implemented Interfaces:
ICompatibilityManager

public class CompatibilityManager extends Object implements ICompatibilityManager
CompatibilityManager handling certain list and maps of itemStacks of certain types.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates the compatibilityManager.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    connectLeafToSapling(net.minecraft.world.level.block.Block leaf, net.minecraft.world.item.ItemStack stack)
    Connect a certain block as leave to an ItemStack as sapling.
    void
    deserialize(@NotNull net.minecraft.network.FriendlyByteBuf buf, net.minecraft.client.multiplayer.ClientLevel level)
    Receive and update lists based on incoming server discovery data.
    void
    discover(@NotNull net.minecraft.world.item.crafting.RecipeManager recipeManager, net.minecraft.world.level.Level level)
    Called server-side *only* to calculate the various lists of items from the registry, recipes, and tags.
    com.google.common.collect.ImmutableSet<net.minecraft.resources.ResourceLocation>
    Get the set of all monsters.
    Just the possible composting inputs, for item filters.
    Map<net.minecraft.world.item.Item,CompostRecipe>
    Get a copy of the list of compost recipes.
    Get a copy of the list of plantables.
    Get a copy of the list of saplings.
    net.minecraft.world.item.CreativeModeTab
    Get the creative tab for a stack.
    int
    Get the creative tab key as int associated.
    Optional<net.minecraft.world.item.DyeColor>
    getDyeColor(net.minecraft.world.item.ItemStack stack)
    Try to work out what dye needs to be used to produce the given color.
    getEdibles(int minNutrition)
    Get a set of all edibles for citizens.
    Get a set of all food items.
    Get a set of all fuel items.
    Get a copy of the list of flowers.
    List<net.minecraft.world.item.ItemStack>
    Getter for the list.
    List<net.minecraft.world.item.ItemStack>
    getListOfMatchingItems(Predicate<net.minecraft.world.item.ItemStack> predicate)
    Get a list of all matching items.
    int
    Get number of detected saplings.
    @Nullable net.minecraft.world.item.ItemStack
    getSaplingForLeaf(net.minecraft.world.level.block.Block block)
    Gets the sapling matching a leaf.
    Get a set of all items (marked to ignore damage but not NBT).
    Get a set of all smeltable ores.
    boolean
    isBreakableOre(@NotNull net.minecraft.world.item.ItemStack stack)
    Check if a stack belongs to a breakable ore.
    boolean
    isLuckyBlock(net.minecraft.world.level.block.Block block)
    If a block is a lucky block which can result in an extra ore drop.
    boolean
    isMineableOre(@NotNull net.minecraft.world.item.ItemStack stack)
    Check if a stack belongs to a minable ore.
    boolean
    isOre(@NotNull net.minecraft.world.item.ItemStack stack)
    Test if an itemStack is an ore.
    boolean
    isOre(net.minecraft.world.level.block.state.BlockState block)
    Checks if a certain Block is an ore.
    boolean
    isPlantable(net.minecraft.world.item.ItemStack itemStack)
    Test if an itemStack is plantable for the florist.
    void
    read(@NotNull net.minecraft.nbt.CompoundTag compound)
    Read Colonies from saved NBT data.
    void
    serialize(@NotNull net.minecraft.network.FriendlyByteBuf buf)
    Transfer server-discovered item lists to client, to avoid double-handling (and potentially getting different answers).
    void
    write(@NotNull net.minecraft.nbt.CompoundTag compound)
    Write colonies to NBT data for saving.

    Methods inherited from class java.lang.Object

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

    • CompatibilityManager

      public CompatibilityManager()
      Instantiates the compatibilityManager.
  • Method Details

    • discover

      public void discover(@NotNull @NotNull net.minecraft.world.item.crafting.RecipeManager recipeManager, net.minecraft.world.level.Level level)
      Called server-side *only* to calculate the various lists of items from the registry, recipes, and tags.
      Specified by:
      discover in interface ICompatibilityManager
      Parameters:
      recipeManager - The vanilla recipe manager.
    • serialize

      public void serialize(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf)
      Description copied from interface: ICompatibilityManager
      Transfer server-discovered item lists to client, to avoid double-handling (and potentially getting different answers).
      Specified by:
      serialize in interface ICompatibilityManager
      Parameters:
      buf - serialization buffer
    • deserialize

      public void deserialize(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf, net.minecraft.client.multiplayer.ClientLevel level)
      Description copied from interface: ICompatibilityManager
      Receive and update lists based on incoming server discovery data. Note: anything based purely on the registries and configs can be safely recalculated here. But anything based on tags or recipes must be updated purely via the packet, because this can be called before the client has the latest tags/recipes.
      Specified by:
      deserialize in interface ICompatibilityManager
      Parameters:
      buf - deserialization buffer
    • getListOfAllItems

      public List<net.minecraft.world.item.ItemStack> getListOfAllItems()
      Getter for the list.
      Specified by:
      getListOfAllItems in interface ICompatibilityManager
      Returns:
      the list of itemStacks.
    • getListOfMatchingItems

      public List<net.minecraft.world.item.ItemStack> getListOfMatchingItems(Predicate<net.minecraft.world.item.ItemStack> predicate)
      Description copied from interface: ICompatibilityManager
      Get a list of all matching items.
      Specified by:
      getListOfMatchingItems in interface ICompatibilityManager
      Returns:
      the immutable list.
    • getSetOfAllItems

      public Set<ItemStorage> getSetOfAllItems()
      Description copied from interface: ICompatibilityManager
      Get a set of all items (marked to ignore damage but not NBT).
      Specified by:
      getSetOfAllItems in interface ICompatibilityManager
      Returns:
      the immutable set.
    • isPlantable

      public boolean isPlantable(net.minecraft.world.item.ItemStack itemStack)
      Description copied from interface: ICompatibilityManager
      Test if an itemStack is plantable for the florist.
      Specified by:
      isPlantable in interface ICompatibilityManager
      Parameters:
      itemStack - the stack to check.
      Returns:
      true if so.
    • isLuckyBlock

      public boolean isLuckyBlock(net.minecraft.world.level.block.Block block)
      Description copied from interface: ICompatibilityManager
      If a block is a lucky block which can result in an extra ore drop.
      Specified by:
      isLuckyBlock in interface ICompatibilityManager
      Parameters:
      block - the block to check.
      Returns:
      true if so.
    • getSaplingForLeaf

      @Nullable public @Nullable net.minecraft.world.item.ItemStack getSaplingForLeaf(net.minecraft.world.level.block.Block block)
      Description copied from interface: ICompatibilityManager
      Gets the sapling matching a leaf.
      Specified by:
      getSaplingForLeaf in interface ICompatibilityManager
      Parameters:
      block - the leaves.
      Returns:
      the sapling stack or null.
    • getCopyOfSaplings

      public Set<ItemStorage> getCopyOfSaplings()
      Description copied from interface: ICompatibilityManager
      Get a copy of the list of saplings.
      Specified by:
      getCopyOfSaplings in interface ICompatibilityManager
      Returns:
      the list of saplings.
    • getFuel

      public Set<ItemStorage> getFuel()
      Description copied from interface: ICompatibilityManager
      Get a set of all fuel items.
      Specified by:
      getFuel in interface ICompatibilityManager
      Returns:
      an immutable set.
    • getFood

      public Set<ItemStorage> getFood()
      Description copied from interface: ICompatibilityManager
      Get a set of all food items.
      Specified by:
      getFood in interface ICompatibilityManager
      Returns:
      an immutable set.
    • getEdibles

      public Set<ItemStorage> getEdibles(int minNutrition)
      Description copied from interface: ICompatibilityManager
      Get a set of all edibles for citizens.
      Specified by:
      getEdibles in interface ICompatibilityManager
      Parameters:
      minNutrition - the min nutrition of the food.
      Returns:
      list of edible food.
    • getSmeltableOres

      public Set<ItemStorage> getSmeltableOres()
      Description copied from interface: ICompatibilityManager
      Get a set of all smeltable ores.
      Specified by:
      getSmeltableOres in interface ICompatibilityManager
      Returns:
      an immutable set.
    • getCopyOfCompostRecipes

      public Map<net.minecraft.world.item.Item,CompostRecipe> getCopyOfCompostRecipes()
      Description copied from interface: ICompatibilityManager
      Get a copy of the list of compost recipes.
      Specified by:
      getCopyOfCompostRecipes in interface ICompatibilityManager
      Returns:
      the list of compost recipes, indexed by input item.
    • getCompostInputs

      public Set<ItemStorage> getCompostInputs()
      Description copied from interface: ICompatibilityManager
      Just the possible composting inputs, for item filters.
      Specified by:
      getCompostInputs in interface ICompatibilityManager
      Returns:
      the set of compost input items.
    • getCopyOfPlantables

      public Set<ItemStorage> getCopyOfPlantables()
      Description copied from interface: ICompatibilityManager
      Get a copy of the list of plantables.
      Specified by:
      getCopyOfPlantables in interface ICompatibilityManager
      Returns:
      the list of plantables.
    • getImmutableFlowers

      public Set<ItemStorage> getImmutableFlowers()
      Description copied from interface: ICompatibilityManager
      Get a copy of the list of flowers.
      Specified by:
      getImmutableFlowers in interface ICompatibilityManager
      Returns:
      the list of flowers.
    • isOre

      public boolean isOre(net.minecraft.world.level.block.state.BlockState block)
      Description copied from interface: ICompatibilityManager
      Checks if a certain Block is an ore.
      Specified by:
      isOre in interface ICompatibilityManager
      Parameters:
      block - the block to check.
      Returns:
      boolean if so.
    • isOre

      public boolean isOre(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ICompatibilityManager
      Test if an itemStack is an ore.
      Specified by:
      isOre in interface ICompatibilityManager
      Parameters:
      stack - the stack to test.
      Returns:
      true if so.
    • isMineableOre

      public boolean isMineableOre(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ICompatibilityManager
      Check if a stack belongs to a minable ore.
      Specified by:
      isMineableOre in interface ICompatibilityManager
      Parameters:
      stack - the stack to test.
      Returns:
      true if so.
    • isBreakableOre

      public boolean isBreakableOre(@NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ICompatibilityManager
      Check if a stack belongs to a breakable ore.
      Specified by:
      isBreakableOre in interface ICompatibilityManager
      Parameters:
      stack - the stack to test.
      Returns:
      true if so.
    • write

      public void write(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: ICompatibilityManager
      Write colonies to NBT data for saving.
      Specified by:
      write in interface ICompatibilityManager
      Parameters:
      compound - NBT-Tag.
    • read

      public void read(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: ICompatibilityManager
      Read Colonies from saved NBT data.
      Specified by:
      read in interface ICompatibilityManager
      Parameters:
      compound - NBT Tag.
    • connectLeafToSapling

      public void connectLeafToSapling(net.minecraft.world.level.block.Block leaf, net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ICompatibilityManager
      Connect a certain block as leave to an ItemStack as sapling.
      Specified by:
      connectLeafToSapling in interface ICompatibilityManager
      Parameters:
      leaf - the block to connect the sapling to.
      stack - the sapling.
    • getCreativeTab

      public net.minecraft.world.item.CreativeModeTab getCreativeTab(ItemStorage checkItem)
      Description copied from interface: ICompatibilityManager
      Get the creative tab for a stack.
      Specified by:
      getCreativeTab in interface ICompatibilityManager
      Parameters:
      checkItem - the storage wrapper.
    • getCreativeTabKey

      public int getCreativeTabKey(ItemStorage checkItem)
      Description copied from interface: ICompatibilityManager
      Get the creative tab key as int associated.
      Specified by:
      getCreativeTabKey in interface ICompatibilityManager
      Parameters:
      checkItem - the item to check.
      Returns:
      the number or default.
    • getAllMonsters

      public com.google.common.collect.ImmutableSet<net.minecraft.resources.ResourceLocation> getAllMonsters()
      Description copied from interface: ICompatibilityManager
      Get the set of all monsters.
      Specified by:
      getAllMonsters in interface ICompatibilityManager
      Returns:
      the set.
    • getNumberOfSaplings

      public int getNumberOfSaplings()
      Description copied from interface: ICompatibilityManager
      Get number of detected saplings.
      Specified by:
      getNumberOfSaplings in interface ICompatibilityManager
      Returns:
      the number of saplings.
    • getDyeColor

      public Optional<net.minecraft.world.item.DyeColor> getDyeColor(net.minecraft.world.item.ItemStack stack)
      Description copied from interface: ICompatibilityManager
      Try to work out what dye needs to be used to produce the given color.
      Specified by:
      getDyeColor in interface ICompatibilityManager
      Parameters:
      stack - the already-dyed stack.
      Returns:
      the dye color required, or empty if there is no such dye.