Class CompatibilityManager
java.lang.Object
com.minecolonies.api.compatibility.CompatibilityManager
- All Implemented Interfaces:
ICompatibilityManager
CompatibilityManager handling certain list and maps of itemStacks of certain types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnectLeafToSapling(net.minecraft.world.level.block.Block leaf, net.minecraft.world.item.ItemStack stack) Connect a certain block as leave to an ItemStack as sapling.voiddeserialize(@NotNull net.minecraft.network.FriendlyByteBuf buf, net.minecraft.client.multiplayer.ClientLevel level) Receive and update lists based on incoming server discovery data.voiddiscover(@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.CreativeModeTabgetCreativeTab(ItemStorage checkItem) Get the creative tab for a stack.intgetCreativeTabKey(ItemStorage checkItem) 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.getFood()Get a set of all food items.getFuel()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.intGet number of detected saplings.@Nullable net.minecraft.world.item.ItemStackgetSaplingForLeaf(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.booleanisBreakableOre(@NotNull net.minecraft.world.item.ItemStack stack) Check if a stack belongs to a breakable ore.booleanisLuckyBlock(net.minecraft.world.level.block.Block block) If a block is a lucky block which can result in an extra ore drop.booleanisMineableOre(@NotNull net.minecraft.world.item.ItemStack stack) Check if a stack belongs to a minable ore.booleanisOre(@NotNull net.minecraft.world.item.ItemStack stack) Test if an itemStack is an ore.booleanisOre(net.minecraft.world.level.block.state.BlockState block) Checks if a certain Block is an ore.booleanisPlantable(net.minecraft.world.item.ItemStack itemStack) Test if an itemStack is plantable for the florist.voidread(@NotNull net.minecraft.nbt.CompoundTag compound) Read Colonies from saved NBT data.voidserialize(@NotNull net.minecraft.network.FriendlyByteBuf buf) Transfer server-discovered item lists to client, to avoid double-handling (and potentially getting different answers).voidwrite(@NotNull net.minecraft.nbt.CompoundTag compound) Write colonies to NBT data for saving.
-
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:
discoverin interfaceICompatibilityManager- Parameters:
recipeManager- The vanilla recipe manager.
-
serialize
public void serialize(@NotNull @NotNull net.minecraft.network.FriendlyByteBuf buf) Description copied from interface:ICompatibilityManagerTransfer server-discovered item lists to client, to avoid double-handling (and potentially getting different answers).- Specified by:
serializein interfaceICompatibilityManager- 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:ICompatibilityManagerReceive 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:
deserializein interfaceICompatibilityManager- Parameters:
buf- deserialization buffer
-
getListOfAllItems
Getter for the list.- Specified by:
getListOfAllItemsin interfaceICompatibilityManager- 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:ICompatibilityManagerGet a list of all matching items.- Specified by:
getListOfMatchingItemsin interfaceICompatibilityManager- Returns:
- the immutable list.
-
getSetOfAllItems
Description copied from interface:ICompatibilityManagerGet a set of all items (marked to ignore damage but not NBT).- Specified by:
getSetOfAllItemsin interfaceICompatibilityManager- Returns:
- the immutable set.
-
isPlantable
public boolean isPlantable(net.minecraft.world.item.ItemStack itemStack) Description copied from interface:ICompatibilityManagerTest if an itemStack is plantable for the florist.- Specified by:
isPlantablein interfaceICompatibilityManager- 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:ICompatibilityManagerIf a block is a lucky block which can result in an extra ore drop.- Specified by:
isLuckyBlockin interfaceICompatibilityManager- 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:ICompatibilityManagerGets the sapling matching a leaf.- Specified by:
getSaplingForLeafin interfaceICompatibilityManager- Parameters:
block- the leaves.- Returns:
- the sapling stack or null.
-
getCopyOfSaplings
Description copied from interface:ICompatibilityManagerGet a copy of the list of saplings.- Specified by:
getCopyOfSaplingsin interfaceICompatibilityManager- Returns:
- the list of saplings.
-
getFuel
Description copied from interface:ICompatibilityManagerGet a set of all fuel items.- Specified by:
getFuelin interfaceICompatibilityManager- Returns:
- an immutable set.
-
getFood
Description copied from interface:ICompatibilityManagerGet a set of all food items.- Specified by:
getFoodin interfaceICompatibilityManager- Returns:
- an immutable set.
-
getEdibles
Description copied from interface:ICompatibilityManagerGet a set of all edibles for citizens.- Specified by:
getEdiblesin interfaceICompatibilityManager- Parameters:
minNutrition- the min nutrition of the food.- Returns:
- list of edible food.
-
getSmeltableOres
Description copied from interface:ICompatibilityManagerGet a set of all smeltable ores.- Specified by:
getSmeltableOresin interfaceICompatibilityManager- Returns:
- an immutable set.
-
getCopyOfCompostRecipes
Description copied from interface:ICompatibilityManagerGet a copy of the list of compost recipes.- Specified by:
getCopyOfCompostRecipesin interfaceICompatibilityManager- Returns:
- the list of compost recipes, indexed by input item.
-
getCompostInputs
Description copied from interface:ICompatibilityManagerJust the possible composting inputs, for item filters.- Specified by:
getCompostInputsin interfaceICompatibilityManager- Returns:
- the set of compost input items.
-
getCopyOfPlantables
Description copied from interface:ICompatibilityManagerGet a copy of the list of plantables.- Specified by:
getCopyOfPlantablesin interfaceICompatibilityManager- Returns:
- the list of plantables.
-
getImmutableFlowers
Description copied from interface:ICompatibilityManagerGet a copy of the list of flowers.- Specified by:
getImmutableFlowersin interfaceICompatibilityManager- Returns:
- the list of flowers.
-
isOre
public boolean isOre(net.minecraft.world.level.block.state.BlockState block) Description copied from interface:ICompatibilityManagerChecks if a certain Block is an ore.- Specified by:
isOrein interfaceICompatibilityManager- 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:ICompatibilityManagerTest if an itemStack is an ore.- Specified by:
isOrein interfaceICompatibilityManager- 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:ICompatibilityManagerCheck if a stack belongs to a minable ore.- Specified by:
isMineableOrein interfaceICompatibilityManager- 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:ICompatibilityManagerCheck if a stack belongs to a breakable ore.- Specified by:
isBreakableOrein interfaceICompatibilityManager- 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:ICompatibilityManagerWrite colonies to NBT data for saving.- Specified by:
writein interfaceICompatibilityManager- Parameters:
compound- NBT-Tag.
-
read
public void read(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Description copied from interface:ICompatibilityManagerRead Colonies from saved NBT data.- Specified by:
readin interfaceICompatibilityManager- 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:ICompatibilityManagerConnect a certain block as leave to an ItemStack as sapling.- Specified by:
connectLeafToSaplingin interfaceICompatibilityManager- Parameters:
leaf- the block to connect the sapling to.stack- the sapling.
-
getCreativeTab
Description copied from interface:ICompatibilityManagerGet the creative tab for a stack.- Specified by:
getCreativeTabin interfaceICompatibilityManager- Parameters:
checkItem- the storage wrapper.
-
getCreativeTabKey
Description copied from interface:ICompatibilityManagerGet the creative tab key as int associated.- Specified by:
getCreativeTabKeyin interfaceICompatibilityManager- 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:ICompatibilityManagerGet the set of all monsters.- Specified by:
getAllMonstersin interfaceICompatibilityManager- Returns:
- the set.
-
getNumberOfSaplings
public int getNumberOfSaplings()Description copied from interface:ICompatibilityManagerGet number of detected saplings.- Specified by:
getNumberOfSaplingsin interfaceICompatibilityManager- Returns:
- the number of saplings.
-
getDyeColor
public Optional<net.minecraft.world.item.DyeColor> getDyeColor(net.minecraft.world.item.ItemStack stack) Description copied from interface:ICompatibilityManagerTry to work out what dye needs to be used to produce the given color.- Specified by:
getDyeColorin interfaceICompatibilityManager- Parameters:
stack- the already-dyed stack.- Returns:
- the dye color required, or empty if there is no such dye.
-