Class TravellingManager

java.lang.Object
com.minecolonies.core.colony.managers.TravellingManager
All Implemented Interfaces:
ITravellingManager, net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>

public class TravellingManager extends Object implements ITravellingManager, net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
Implementation of the travelling system and its API. Keeps track of the travelling destination and progress of a given party.

Does not handle any interactions with the entities or the citizens.

  • Constructor Details

    • TravellingManager

      public TravellingManager(IColony colony)
  • Method Details

    • isTravelling

      public boolean isTravelling(int citizenId)
      Description copied from interface: ITravellingManager
      Indicates whether the citizen with the given id is travelling or not.
      Specified by:
      isTravelling in interface ITravellingManager
      Parameters:
      citizenId - The citizen id to check for.
      Returns:
      True when travelling, false when not.
    • getTravellingTargetFor

      public Optional<net.minecraft.core.BlockPos> getTravellingTargetFor(int citizenId)
      Description copied from interface: ITravellingManager
      Gets the travelling target, when travelling, for the citizen with the given id.
      Specified by:
      getTravellingTargetFor in interface ITravellingManager
      Parameters:
      citizenId - The id of the citizen to get the target for.
      Returns:
      An optional with the travelling target. The optional is empty when the citizen is not travelling.
    • startTravellingTo

      public void startTravellingTo(int citizenId, net.minecraft.core.BlockPos target, int travelTimeInTicks)
      Description copied from interface: ITravellingManager
      Triggers the travelling logic for the citizen with the given id.

      Does not despawn the entity. Discard it after calling this method.

      Specified by:
      startTravellingTo in interface ITravellingManager
      Parameters:
      citizenId - The id of the citizen.
      target - The target to which the citizen is travelling, aka his respawn point.
      travelTimeInTicks - The time in ticks which needs to have passed for the travelling to complete.
    • finishTravellingFor

      public void finishTravellingFor(int citizenId)
      Description copied from interface: ITravellingManager
      Triggers the cleanup of the travelling data when the citizen finishes travelling, either by design, or through an abort.

      Does not spawn the entity. Trigger an entity update for the citizen to properly spawn it.

      Specified by:
      finishTravellingFor in interface ITravellingManager
      Parameters:
      citizenId - The id of the citizen to stop the travelling for.
    • recallAllTravellingCitizens

      public void recallAllTravellingCitizens()
      Description copied from interface: ITravellingManager
      Triggers the recall of all travelling citizens regards of state of completion.
      Specified by:
      recallAllTravellingCitizens in interface ITravellingManager
    • onTick

      public boolean onTick()
    • serializeNBT

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

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