Class AbstractBuildingView

java.lang.Object
com.minecolonies.core.colony.buildings.views.AbstractBuildingView
All Implemented Interfaces:
ICommonBuilding, IBuildingView, IModuleContainerView, IRequester
Direct Known Subclasses:
AbstractBuildingBuilderView, AbstractBuildingGuards.View, BuildingBarracks.View, BuildingBeekeeper.View, BuildingCook.View, BuildingLumberjack.View, BuildingMysticalSite.View, BuildingTownHall.View, BuildingWareHouse.View, EmptyView, LivingBuildingView, PostBox.View

public abstract class AbstractBuildingView extends Object implements IBuildingView
The AbstractBuilding View is the client-side representation of a AbstractBuilding. Views contain the AbstractBuilding's data that is relevant to a Client, in a more client-friendly form. Mutable operations on a View result in a message to the server to perform the operation.
  • Field Details

    • moduleViews

      protected it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap<IBuildingModuleView> moduleViews
      Set of building modules this building has.
  • Constructor Details

    • AbstractBuildingView

      protected AbstractBuildingView(IColonyView c, @NotNull @NotNull net.minecraft.core.BlockPos l)
      Creates a building view.
      Parameters:
      c - ColonyView the building is in.
      l - The location of the building.
  • Method Details

    • getID

      @NotNull public @NotNull net.minecraft.core.BlockPos getID()
      Gets the id for this building.
      Specified by:
      getID in interface IBuildingView
      Returns:
      A BlockPos because the building ID is its location.
    • getPosition

      @NotNull public @NotNull net.minecraft.core.BlockPos getPosition()
      Gets the location of this building.
      Specified by:
      getPosition in interface ICommonBuilding
      Returns:
      A BlockPos, where this building is.
    • getParent

      @NotNull public @NotNull net.minecraft.core.BlockPos getParent()
      Description copied from interface: IBuildingView
      Get the parent building
      Specified by:
      getParent in interface IBuildingView
      Returns:
    • getBuildingLevel

      public int getBuildingLevel()
      Get the current level of the building.
      Specified by:
      getBuildingLevel in interface ICommonBuilding
      Returns:
      AbstractBuilding current level.
    • getBuildingMaxLevel

      public int getBuildingMaxLevel()
      Get the max level of the building.
      Specified by:
      getBuildingMaxLevel in interface IBuildingView
      Returns:
      AbstractBuilding max level.
    • isBuildingMaxLevel

      public boolean isBuildingMaxLevel()
      Checks if this building is at its max level.
      Specified by:
      isBuildingMaxLevel in interface IBuildingView
      Returns:
      true if the building is at its max level.
    • getCurrentWorkOrderLevel

      public int getCurrentWorkOrderLevel()
      Get the current work order level.
      Specified by:
      getCurrentWorkOrderLevel in interface IBuildingView
      Returns:
      0 if none, othewise the current level worked on
    • getStructurePath

      public String getStructurePath()
      Getter for the schematic name.
      Specified by:
      getStructurePath in interface IBuildingView
      Returns:
      the schematic name.
    • getCustomName

      public String getCustomName()
      Getter for the custom building name.
      Specified by:
      getCustomName in interface IBuildingView
      Returns:
      the name.
    • getStructurePack

      public String getStructurePack()
      Getter for the style.
      Specified by:
      getStructurePack in interface IBuildingView
      Returns:
      the style string.
    • getRotationMirror

      public com.ldtteam.structurize.api.RotationMirror getRotationMirror()
      Getter for the rotation.
      Specified by:
      getRotationMirror in interface IBuildingView
      Returns:
      the rotation.
    • hasWorkOrder

      public boolean hasWorkOrder()
      Get the current work order level.
      Specified by:
      hasWorkOrder in interface IBuildingView
      Returns:
      0 if none, othewise the current level worked on
    • isBuilding

      public boolean isBuilding()
      Description copied from interface: IBuildingView
      Check if the building is current being built.
      Specified by:
      isBuilding in interface IBuildingView
      Returns:
      true if so.
    • isRepairing

      public boolean isRepairing()
      Description copied from interface: IBuildingView
      Check if the building is currently being repaired.
      Specified by:
      isRepairing in interface IBuildingView
      Returns:
      true if so.
    • isDeconstructing

      public boolean isDeconstructing()
      Description copied from interface: IBuildingView
      Check if the building is currently being deconstructed..
      Specified by:
      isDeconstructing in interface IBuildingView
      Returns:
      true if so.
    • getClaimRadius

      public int getClaimRadius()
      Get the claim radius for the building.
      Specified by:
      getClaimRadius in interface IBuildingView
      Returns:
      the radius.
    • getContainers

      public List<net.minecraft.core.BlockPos> getContainers()
      Returns the Container List
      Specified by:
      getContainers in interface ICommonBuilding
      Returns:
      containerList.
    • openGui

      public void openGui(boolean shouldOpenInv)
      Open the associated blockui window for this building. If the player is sneaking open the inventory else open the GUI directly.
      Specified by:
      openGui in interface IBuildingView
      Parameters:
      shouldOpenInv - if the player is sneaking.
    • getWindow

      @NotNull public @NotNull com.ldtteam.blockui.views.BOWindow getWindow()
      Will return the window if this building has an associated blockui window.
      Specified by:
      getWindow in interface IBuildingView
      Returns:
      blockui window.
    • deserialize

      public void deserialize(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf)
      Read this view from a RegistryFriendlyByteBuf.
      Specified by:
      deserialize in interface IBuildingView
      Parameters:
      buf - The buffer to read this view from.
    • getPrestige

      public int getPrestige()
      Description copied from interface: ICommonBuilding
      Get the prestige value of the building.
      Specified by:
      getPrestige in interface ICommonBuilding
      Returns:
      the prestige value.
    • getOpenRequestsByCitizen

      public Map<Integer,Collection<IToken<?>>> getOpenRequestsByCitizen()
      Specified by:
      getOpenRequestsByCitizen in interface IBuildingView
    • getCitizensByRequest

      protected Map<IToken<?>,Integer> getCitizensByRequest()
    • getOpenRequestsOfType

      public <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getOpenRequestsOfType(@NotNull @NotNull ICitizenDataView citizenData, Class<R> requestType)
      Specified by:
      getOpenRequestsOfType in interface IBuildingView
    • getOpenRequests

      public com.google.common.collect.ImmutableList<IRequest<?>> getOpenRequests(@NotNull @NotNull ICitizenDataView data)
      Specified by:
      getOpenRequests in interface IBuildingView
    • getOpenRequestsOfBuilding

      public com.google.common.collect.ImmutableList<IRequest<?>> getOpenRequestsOfBuilding()
      Specified by:
      getOpenRequestsOfBuilding in interface IBuildingView
    • getColony

      public IColonyView getColony()
      Gets the ColonyView that this building belongs to.
      Specified by:
      getColony in interface IBuildingView
      Specified by:
      getColony in interface ICommonBuilding
      Returns:
      ColonyView, client side interpretations of Colony.
    • getOpenRequestsOfTypeFiltered

      public <R> com.google.common.collect.ImmutableList<IRequest<? extends R>> getOpenRequestsOfTypeFiltered(@NotNull @NotNull ICitizenDataView citizenData, Class<R> requestType, Predicate<IRequest<? extends R>> filter)
      Specified by:
      getOpenRequestsOfTypeFiltered in interface IBuildingView
    • getId

      public IToken<?> getId()
      Description copied from interface: IRequester
      Method to get the ID of a given requester.
      Specified by:
      getId in interface IRequester
      Returns:
      The id of this requester.
    • onRequestedRequestComplete

      public void onRequestedRequestComplete(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request)
      Description copied from interface: IRequester
      Method called by the request system to notify this requester that a request is complete.
      Specified by:
      onRequestedRequestComplete in interface IRequester
      Parameters:
      manager - the request manager.
      request - the request.
    • onRequestedRequestCancelled

      public void onRequestedRequestCancelled(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request)
      Description copied from interface: IRequester
      Method called by the request system to notify this requester that a request has been overruled.
      Specified by:
      onRequestedRequestCancelled in interface IRequester
      Parameters:
      manager - the request manager.
      request - the request.
    • getRequesterDisplayName

      @NotNull public @NotNull net.minecraft.network.chat.MutableComponent getRequesterDisplayName(@NotNull @NotNull IRequestManager manager, @NotNull @NotNull IRequest<?> request)
      Description copied from interface: IRequester
      Gets the name of the requester that requested the request given by the token.
      Specified by:
      getRequesterDisplayName in interface IRequester
      Parameters:
      manager - the request manager.
      request - the request for which the name of the requester is retrieved
      Returns:
      The display name of the requester.
    • getLocation

      @NotNull public @NotNull ILocation getLocation()
      Description copied from interface: IRequester
      Method to get the location of this locatable.
      Specified by:
      getLocation in interface IRequester
      Returns:
      the location.
    • getBuildingDmPrio

      public int getBuildingDmPrio()
      Description copied from interface: IBuildingView
      Get the delivery priority of the building.
      Specified by:
      getBuildingDmPrio in interface IBuildingView
      Returns:
      int, delivery priority.
    • getResolverIds

      public com.google.common.collect.ImmutableCollection<IToken<?>> getResolverIds()
      Specified by:
      getResolverIds in interface IBuildingView
    • setCustomName

      public void setCustomName(String name)
      Description copied from interface: IBuildingView
      Setter for the custom name. Sets the name on the client side and sends it to the server.
      Specified by:
      setCustomName in interface IBuildingView
      Parameters:
      name - the new name.
    • isDeconstructed

      public boolean isDeconstructed()
      Description copied from interface: IBuildingView
      Check if the building was deconstructed.
      Specified by:
      isDeconstructed in interface IBuildingView
      Returns:
      true if so.
    • getModuleView

      public IBuildingModuleView getModuleView(int id)
      Description copied from interface: IModuleContainerView
      Get the first module with a particular class or interface.
      Specified by:
      getModuleView in interface IModuleContainerView
      Returns:
      the module or empty if not existent.
    • getModuleView

      public <M extends IBuildingModule, V extends IBuildingModuleView> V getModuleView(BuildingEntry.ModuleProducer<M,V> producer)
      Description copied from interface: IModuleContainerView
      Get the first module with a particular class or interface.
      Specified by:
      getModuleView in interface IModuleContainerView
      Returns:
      the module or empty if not existent.
    • hasModuleView

      public boolean hasModuleView(BuildingEntry.ModuleProducer producer)
      Description copied from interface: IModuleContainerView
      Check if the object has a particular module.
      Specified by:
      hasModuleView in interface IModuleContainerView
      Parameters:
      producer - the module producer for the module
      Returns:
      true if so.
    • getModuleViewByType

      @NotNull public <T extends IBuildingModuleView> T getModuleViewByType(Class<T> clazz)
      Description copied from interface: IModuleContainerView
      Get the first module view matching the class.
      Specified by:
      getModuleViewByType in interface IModuleContainerView
      Type Parameters:
      T - the type of module returned.
      Parameters:
      clazz - the class to match.
      Returns:
      the module.
    • getModuleViewMatching

      public <T extends IBuildingModuleView> T getModuleViewMatching(Class<T> clazz, Predicate<? super T> modulePredicate)
      Description copied from interface: IModuleContainerView
      Get the module view matching a certain predicate.
      Specified by:
      getModuleViewMatching in interface IModuleContainerView
      Type Parameters:
      T - the optional type.
      Parameters:
      clazz - the class of the module.
      modulePredicate - the predicate to match.
      Returns:
      the module.
    • getModuleViews

      @NotNull public <T extends IBuildingModuleView> @NotNull List<T> getModuleViews(Class<T> clazz)
      Description copied from interface: IModuleContainerView
      Get a list of all modules matching a specific class.
      Specified by:
      getModuleViews in interface IModuleContainerView
      Type Parameters:
      T - the type of module.
      Parameters:
      clazz - the class to match.
      Returns:
      the list or empty if doesn't exist.
    • registerModule

      public void registerModule(IBuildingModuleView iModuleView)
      Description copied from interface: IModuleContainerView
      Register a view module with the building.
      Specified by:
      registerModule in interface IModuleContainerView
      Parameters:
      iModuleView - the view.
    • getAllModuleViews

      public List<IBuildingModuleView> getAllModuleViews()
      Description copied from interface: IModuleContainerView
      Get all module views in a list.
      Specified by:
      getAllModuleViews in interface IModuleContainerView
      Returns:
      the list of views.
    • getBuildingType

      public final BuildingEntry getBuildingType()
      Description copied from interface: ICommonBuilding
      Get the Building type
      Specified by:
      getBuildingType in interface ICommonBuilding
      Returns:
      building type
    • setBuildingType

      public void setBuildingType(BuildingEntry buildingType)
      Description copied from interface: IBuildingView
      Set the building type
      Specified by:
      setBuildingType in interface IBuildingView
      Parameters:
      buildingType -
    • getAllAssignedCitizens

      public Set<Integer> getAllAssignedCitizens()
      Description copied from interface: IBuildingView
      Get the citizen ids of all assigned citizens to this building.
      Specified by:
      getAllAssignedCitizens in interface IBuildingView
      Returns:
      the set of ids.
    • allowsAssignment

      public boolean allowsAssignment()
      Description copied from interface: IBuildingView
      Check if the building currently allows assignment of citizens.
      Specified by:
      allowsAssignment in interface IBuildingView
      Returns:
      true if so.