Class AbstractBuildingStructureBuilder

All Implemented Interfaces:
IBuilding, IBuildingContainer, ICommonBuilding, ISchematicProvider, IBuildingModuleContainer, IModuleContainer<IBuildingModule>, IRequester, IRequestResolverProvider, IItemHandlerCapProvider, net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
Direct Known Subclasses:
BuildingBuilder, BuildingMiner

public abstract class AbstractBuildingStructureBuilder extends AbstractBuilding
The structureBuilder building.
  • Field Details

    • MAX_BUILDING_LEVEL

      public static final int MAX_BUILDING_LEVEL
      The maximum upgrade of the building.
      See Also:
  • Constructor Details

    • AbstractBuildingStructureBuilder

      public AbstractBuildingStructureBuilder(IColony c, net.minecraft.core.BlockPos l)
      Public constructor of the building, creates an object of the building.
      Parameters:
      c - the colony.
      l - the position.
  • Method Details

    • getMaxBuildingLevel

      public int getMaxBuildingLevel()
      Getter of the max building level.
      Specified by:
      getMaxBuildingLevel in interface ISchematicProvider
      Overrides:
      getMaxBuildingLevel in class AbstractBuilding
      Returns:
      the integer.
    • buildingRequiresCertainAmountOfItem

      public int buildingRequiresCertainAmountOfItem(net.minecraft.world.item.ItemStack stack, List<ItemStorage> localAlreadyKept, boolean inventory, JobEntry jobEntry)
      Description copied from interface: IBuilding
      Check if the worker requires a certain amount of that item and the alreadykept list contains it. Always leave one stack behind if the worker requires a certain amount of it. Just to be sure.
      Specified by:
      buildingRequiresCertainAmountOfItem in interface IBuilding
      Overrides:
      buildingRequiresCertainAmountOfItem in class AbstractBuilding
      Parameters:
      stack - the stack to check it with.
      localAlreadyKept - already kept items.
      inventory - if it should be in the inventory or in the building.
      jobEntry - the job entry trying to dump.
      Returns:
      the amount which can get dumped or 0 if not.
    • getRequiredItemsAndAmount

      public Map<Predicate<net.minecraft.world.item.ItemStack>,net.minecraft.util.Tuple<Integer,Boolean>> getRequiredItemsAndAmount()
      Description copied from class: AbstractBuilding
      Override this method if you want to keep an amount of items in inventory. When the inventory is full, everything get's dumped into the building chest. But you can use this method to hold some stacks back.
      Specified by:
      getRequiredItemsAndAmount in interface IBuilding
      Overrides:
      getRequiredItemsAndAmount in class AbstractBuilding
      Returns:
      a list of objects which should be kept.
    • forceTransferStack

      public net.minecraft.world.item.ItemStack forceTransferStack(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level world)
      Description copied from class: AbstractBuilding
      Try to transfer a stack to one of the inventories of the building and force the transfer.
      Specified by:
      forceTransferStack in interface IBuilding
      Overrides:
      forceTransferStack in class AbstractBuilding
      Parameters:
      stack - the stack to transfer.
      world - the world to do it in.
      Returns:
      the itemStack which has been replaced or the itemStack which could not be transfered
    • deserializeNBT

      public void deserializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider, net.minecraft.nbt.CompoundTag compound)
      Specified by:
      deserializeNBT in interface IBuildingContainer
      Specified by:
      deserializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      deserializeNBT in class AbstractBuilding
    • serializeNBT

      public net.minecraft.nbt.CompoundTag serializeNBT(@NotNull net.minecraft.core.HolderLookup.Provider provider)
      Specified by:
      serializeNBT in interface IBuildingContainer
      Specified by:
      serializeNBT in interface net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
      Overrides:
      serializeNBT in class AbstractBuilding
    • serializeToView

      public void serializeToView(@NotNull @NotNull net.minecraft.network.RegistryFriendlyByteBuf buf, boolean fullSync)
      Method to serialize data to send it to the view.
      Specified by:
      serializeToView in interface IBuilding
      Overrides:
      serializeToView in class AbstractBuilding
      Parameters:
      buf - the used ByteBuffer.
      fullSync - Whether it's a full sync
    • getNeededResources

      public Map<String,BuildingBuilderResource> getNeededResources()
      Get the needed resources for the current build.
      Returns:
      a new Hashmap.
    • getRequiredResources

      @Nullable public @Nullable BuilderBucket getRequiredResources()
      Get the needed resources for the current build.
      Returns:
      the bucket.
    • hasResourceInBucket

      public boolean hasResourceInBucket(net.minecraft.world.item.ItemStack stack)
      Check if the resources are in the bucket.
      Parameters:
      stack - the stack to check.
      Returns:
      true if so.
    • addNeededResource

      public void addNeededResource(@Nullable @Nullable net.minecraft.world.item.ItemStack res, int amount)
      Add a new resource to the needed list.
      Parameters:
      res - the resource.
      amount - the amount.
    • reduceNeededResource

      public void reduceNeededResource(net.minecraft.world.item.ItemStack res, int amount)
      Reduce a resource of the needed list.
      Parameters:
      res - the resource.
      amount - the amount.
    • resetNeededResources

      public void resetNeededResources()
      Resets the needed resources completely.
    • requiresResourceForBuilding

      public boolean requiresResourceForBuilding(net.minecraft.world.item.ItemStack stack)
      Check if the structureBuilder requires a certain ItemStack for the current construction.
      Parameters:
      stack - the stack to test.
      Returns:
      true if so.
    • setProgressPos

      public void setProgressPos(net.minecraft.core.BlockPos blockPos, BuildingProgressStage stage)
      Set the progress position of the builder.
      Parameters:
      blockPos - the last blockPos.
      stage - the stage to set.
    • getProgress

      @Nullable public @Nullable Tuple<net.minecraft.core.BlockPos,BuildingProgressStage> getProgress()
      Getter for the progress position.
      Returns:
      the current progress and stage.
    • getResourceBatchMultiplier

      public int getResourceBatchMultiplier()
      Batch size to request for resources, used by the Miner to get multiple nodes of supplies
    • getFluidsToRemove

      public Map<Integer,List<net.minecraft.core.BlockPos>> getFluidsToRemove()
      Getter for the blocks to be removed in fluids_remove.
      Returns:
      the blocks to be removed in fluids_remove.
    • checkOrRequestBucket

      public void checkOrRequestBucket(@Nullable @Nullable BuilderBucket requiredResources, ICitizenData worker)
      Check or request if the contents of a specific batch are in the inventory of the building. This ignores the worker inventory (that is remaining stuff from previous rounds, or already belongs to another bucket)
      Parameters:
      requiredResources - the bucket to check and request.
      worker - the worker.
    • nextStage

      public void nextStage()
      Go to the next stage.
    • setTotalStages

      public void setTotalStages(int total)
      Set the total number of stages.
      Parameters:
      total - the total.
    • getNextBucket

      @Nullable public @Nullable BuilderBucket getNextBucket()
      Return the next bucket to work on.
      Returns:
      the next bucket or a tuple with null inside if non available.
    • onWorkOrderCancellation

      public void onWorkOrderCancellation(IWorkOrder workOrder)
      Handle workorder cancellation, reset requests and progress.
      Parameters:
      workOrder - the cancelled workorder.
    • hasWorkOrder

      public boolean hasWorkOrder()
      Does this job have a Work Order it has claimed?
      Returns:
      true if there is a Work Order claimed by this Job
    • getWorkOrder

      public IBuilderWorkOrder getWorkOrder()
      Get the Work Order for the Job. Warning: WorkOrder is not cached
      Returns:
      WorkOrderBuildDecoration for the Build
    • setWorkOrder

      public void setWorkOrder(@Nullable @Nullable IWorkOrder order)
      Set a Work Order for this Job.
      Parameters:
      order - Work Order to associate with this job, or null
    • complete

      public void complete(ICitizenData citizen)
      Do final completion when the Job's current work is complete.
    • setWorkOrderId

      public void setWorkOrderId(int id)
      Deprecated.
      Set workorder ID. Only for backwards compatibility.
      Parameters:
      id - the work order id.