Class RaidManager

java.lang.Object
com.minecolonies.core.colony.events.raid.RaidManager
All Implemented Interfaces:
IRaiderManager

public class RaidManager extends Object implements IRaiderManager
Handles spawning hostile raid events.
  • Field Details

    • SPAWN_MODIFIER

      public static final double SPAWN_MODIFIER
      Spawn modifier to decrease the spawn-rate.
      See Also:
    • MIN_REQUIRED_RAIDLEVEL

      public static final int MIN_REQUIRED_RAIDLEVEL
      Min required raidlevel
      See Also:
  • Constructor Details

    • RaidManager

      public RaidManager(Colony colony)
      Creates the RaidManager for a colony.
      Parameters:
      colony - the colony.
  • Method Details

    • canHaveRaiderEvents

      public boolean canHaveRaiderEvents()
      Description copied from interface: IRaiderManager
      Checks if the raider manager can have raider events.
      Specified by:
      canHaveRaiderEvents in interface IRaiderManager
      Returns:
      true if so.
    • willRaidTonight

      public boolean willRaidTonight()
      Description copied from interface: IRaiderManager
      Checks if raiders will raid tonight.
      Specified by:
      willRaidTonight in interface IRaiderManager
      Returns:
      true if so.
    • setCanHaveRaiderEvents

      public void setCanHaveRaiderEvents(boolean canHave)
      Description copied from interface: IRaiderManager
      Set that the manager can receive raider events.
      Specified by:
      setCanHaveRaiderEvents in interface IRaiderManager
      Parameters:
      canHave - true or false.
    • setRaidNextNight

      public void setRaidNextNight(IRaiderManager.RaidSettings raidSettings)
      Description copied from interface: IRaiderManager
      Set if raiders will raid tonight.
      Specified by:
      setRaidNextNight in interface IRaiderManager
      Parameters:
      raidSettings - the settings for the next raid, or null to stop the next raid.
    • areSpiesEnabled

      public boolean areSpiesEnabled()
      Description copied from interface: IRaiderManager
      Returns whether spies are enabled
      Specified by:
      areSpiesEnabled in interface IRaiderManager
      Returns:
      true if enabled.
    • setSpiesEnabled

      public void setSpiesEnabled(boolean enabled)
      Description copied from interface: IRaiderManager
      Sets whether spies are enabled
      Specified by:
      setSpiesEnabled in interface IRaiderManager
      Parameters:
      enabled - true if enabled.
    • raiderEvent

      public IRaiderManager.RaidSpawnResult raiderEvent(@NotNull @NotNull IRaiderManager.RaidSettings raidSettings)
      Description copied from interface: IRaiderManager
      Trigger a specific type of raid on a colony.
      Specified by:
      raiderEvent in interface IRaiderManager
      Parameters:
      raidSettings - the settings for this raid.
    • calculateSpawnLocation

      public net.minecraft.core.BlockPos calculateSpawnLocation()
      Calculate a random spawn point along the colony's border
      Specified by:
      calculateSpawnLocation in interface IRaiderManager
      Returns:
      Returns the random blockPos
    • isValidSpawnPoint

      public static boolean isValidSpawnPoint(Collection<IBuilding> buildings, net.minecraft.core.BlockPos spawnPos)
      Determines whether the given spawn point is allowed.
      Parameters:
      spawnPos - the spawn point to check
      Returns:
      true if valid
    • getLastSpawnPoints

      public List<net.minecraft.core.BlockPos> getLastSpawnPoints()
      Description copied from interface: IRaiderManager
      Getter for the last spawn points.
      Specified by:
      getLastSpawnPoints in interface IRaiderManager
      Returns:
      a copy of the list
    • calculateRaiderAmount

      public int calculateRaiderAmount(int raidLevel)
      Returns the colonies barbarian level
      Specified by:
      calculateRaiderAmount in interface IRaiderManager
      Parameters:
      raidLevel - the colonies raidlevel
      Returns:
      the amount of barbarians.
    • isRaided

      public boolean isRaided()
      Description copied from interface: IRaiderManager
      Whether the colony is currently raided.
      Specified by:
      isRaided in interface IRaiderManager
      Returns:
      true if so.
    • onNightFall

      public void onNightFall()
      Description copied from interface: IRaiderManager
      Called on nightfall.
      Specified by:
      onNightFall in interface IRaiderManager
    • getNightsSinceLastRaid

      public int getNightsSinceLastRaid()
      Description copied from interface: IRaiderManager
      Returns the amount of nights since the last raid
      Specified by:
      getNightsSinceLastRaid in interface IRaiderManager
      Returns:
      the number of nights.
    • setNightsSinceLastRaid

      public void setNightsSinceLastRaid(int nightsSinceLastRaid)
      Description copied from interface: IRaiderManager
      Sets the amount of nights since the last raid
      Specified by:
      setNightsSinceLastRaid in interface IRaiderManager
      Parameters:
      nightsSinceLastRaid - the nights to set.
    • canRaid

      public boolean canRaid()
      Description copied from interface: IRaiderManager
      Whether the colony can be raided.
      Specified by:
      canRaid in interface IRaiderManager
      Returns:
      true if possible.
    • getColonyRaidLevel

      public int getColonyRaidLevel()
      Takes a colony and spits out that colony's RaidLevel.
      Specified by:
      getColonyRaidLevel in interface IRaiderManager
      Returns:
      an int describing the raid level
    • getRandomBuilding

      @NotNull public @NotNull net.minecraft.core.BlockPos getRandomBuilding()
      Description copied from interface: IRaiderManager
      Returns a random building for raiders to go to, groups up 3 raiders to the same position.
      Specified by:
      getRandomBuilding in interface IRaiderManager
      Returns:
      a random building.
    • getRaidDifficultyModifier

      public double getRaidDifficultyModifier()
      Description copied from interface: IRaiderManager
      Gets the difficulty modifier for raids, default difficulty is 1.0
      Specified by:
      getRaidDifficultyModifier in interface IRaiderManager
      Returns:
      difficulty
    • onLostCitizen

      public void onLostCitizen(ICitizenData citizen)
      Description copied from interface: IRaiderManager
      Called on loosing a citizen, to record deaths during raids
      Specified by:
      onLostCitizen in interface IRaiderManager
      Parameters:
      citizen - that died
    • write

      public void write(net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IRaiderManager
      Writes the raid manager to nbt
      Specified by:
      write in interface IRaiderManager
      Parameters:
      compound - to write to
    • read

      public void read(net.minecraft.nbt.CompoundTag compound)
      Description copied from interface: IRaiderManager
      Reads the raid manager form nbt
      Specified by:
      read in interface IRaiderManager
      Parameters:
      compound - to read from
    • getLostCitizen

      public int getLostCitizen()
      Description copied from interface: IRaiderManager
      Gets the amount of citizens lost in a raid.
      Specified by:
      getLostCitizen in interface IRaiderManager
      Returns:
      amount
    • onRaiderDeath

      public void onRaiderDeath(AbstractEntityMinecoloniesRaider entity)
      Description copied from interface: IRaiderManager
      Called when a raider mob dies
      Specified by:
      onRaiderDeath in interface IRaiderManager
      Parameters:
      entity -
    • onRaidEventFinished

      public void onRaidEventFinished(IColonyRaidEvent finishedRaid)
      Specified by:
      onRaidEventFinished in interface IRaiderManager
    • getLastRaid

      public RaidManager.RaidHistory getLastRaid()
      List of raid histories
      Returns:
    • setPassThroughRaid

      public void setPassThroughRaid()
      Description copied from interface: IRaiderManager
      Notify raid manager of a passing through raid.
      Specified by:
      setPassThroughRaid in interface IRaiderManager
    • getAllRaids

      public List<RaidManager.RaidHistory> getAllRaids()
      Gets all raid histories
      Returns: