Class ItemListModule

java.lang.Object
com.minecolonies.api.colony.buildings.modules.AbstractBuildingModule
com.minecolonies.core.colony.buildings.modules.ItemListModule
All Implemented Interfaces:
IBuildingModule, IItemListModule, IPersistentModule, IHasDirty

public class ItemListModule extends AbstractBuildingModule implements IItemListModule, IPersistentModule
Abstract class for all buildings which require a filterable list of allowed/blocked items.
  • Constructor Details

    • ItemListModule

      public ItemListModule(String id)
      Construct a new grouped itemlist module with the unique list identifier.
      Parameters:
      id - the list id.
    • ItemListModule

      public ItemListModule(String id, ItemStorage... defaultStacks)
      Construct a new grouped itemlist module with the unique list identifier and default values.
      Parameters:
      id - the list id.
      defaultStacks - the default values.
  • Method Details

    • deserializeNBT

      public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IPersistentModule
      Deserialize the module.
      Specified by:
      deserializeNBT in interface IPersistentModule
      Parameters:
      compound - the nbt compound.
    • serializeNBT

      public void serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IPersistentModule
      Serialize the module from a compound.
      Specified by:
      serializeNBT in interface IPersistentModule
      Parameters:
      compound - the compound.
    • addItem

      public void addItem(ItemStorage item)
      Description copied from interface: IItemListModule
      Add an item to the list.
      Specified by:
      addItem in interface IItemListModule
      Parameters:
      item - the item to add.
    • isItemInList

      public boolean isItemInList(ItemStorage item)
      Description copied from interface: IItemListModule
      Check if the item is an allowed item.
      Specified by:
      isItemInList in interface IItemListModule
      Parameters:
      item - the item to check.
      Returns:
      true if so.
    • removeItem

      public void removeItem(ItemStorage item)
      Description copied from interface: IItemListModule
      Remove an item from the list.
      Specified by:
      removeItem in interface IItemListModule
      Parameters:
      item - the item to remove.
    • getList

      public com.google.common.collect.ImmutableList<ItemStorage> getList()
      Description copied from interface: IItemListModule
      Get a specific itemlist.
      Specified by:
      getList in interface IItemListModule
      Returns:
      a copy of the list at ID, or an empty list.
    • getListIdentifier

      public String getListIdentifier()
      Description copied from interface: IItemListModule
      Get the string identifier of the list.
      Specified by:
      getListIdentifier in interface IItemListModule
      Returns:
      the string.
    • clearItems

      public void clearItems()
      Description copied from interface: IItemListModule
      Clear all in the list.
      Specified by:
      clearItems in interface IItemListModule
    • resetToDefaults

      public void resetToDefaults()
      Description copied from interface: IItemListModule
      Reset to defaults (usually but not necessarily the same as IItemListModule.clearItems()).
      Specified by:
      resetToDefaults in interface IItemListModule
    • serializeToView

      public void serializeToView(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
      Description copied from interface: IBuildingModule
      Serialization method to send the module data to the client side.
      Specified by:
      serializeToView in interface IBuildingModule
      Parameters:
      buf - the buffer to write it to.
    • getId

      public String getId()
      Description copied from interface: IItemListModule
      Get the unique id of this module.
      Specified by:
      getId in interface IItemListModule
      Returns:
      the id.