Class RaidManager
java.lang.Object
com.minecolonies.core.colony.events.raid.RaidManager
- All Implemented Interfaces:
IRaiderManager
Handles spawning hostile raid events.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classData holder for raid historystatic classData holder for raid spawnsNested classes/interfaces inherited from interface com.minecolonies.api.colony.managers.interfaces.IRaiderManager
IRaiderManager.RaidSettings, IRaiderManager.RaidSpawnResult -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intMin required raidlevelstatic final doubleSpawn modifier to decrease the spawn-rate. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether spies are enabledintcalculateRaiderAmount(int raidLevel) Returns the colonies barbarian levelnet.minecraft.core.BlockPosCalculate a random spawn point along the colony's borderbooleanChecks if the raider manager can have raider events.booleancanRaid()Whether the colony can be raided.Gets all raid historiesintTakes a colony and spits out that colony's RaidLevel.List of raid historiesList<net.minecraft.core.BlockPos>Getter for the last spawn points.intGets the amount of citizens lost in a raid.intReturns the amount of nights since the last raiddoubleGets the difficulty modifier for raids, default difficulty is 1.0@NotNull net.minecraft.core.BlockPosReturns a random building for raiders to go to, groups up 3 raiders to the same position.booleanisRaided()Whether the colony is currently raided.static booleanisValidSpawnPoint(Collection<IBuilding> buildings, net.minecraft.core.BlockPos spawnPos) Determines whether the given spawn point is allowed.voidonLostCitizen(ICitizenData citizen) Called on loosing a citizen, to record deaths during raidsvoidCalled on nightfall.voidCalled when a raider mob diesvoidonRaidEventFinished(IColonyRaidEvent finishedRaid) raiderEvent(@NotNull IRaiderManager.RaidSettings raidSettings) Trigger a specific type of raid on a colony.voidread(net.minecraft.nbt.CompoundTag compound) Reads the raid manager form nbtvoidsetCanHaveRaiderEvents(boolean canHave) Set that the manager can receive raider events.voidsetNightsSinceLastRaid(int nightsSinceLastRaid) Sets the amount of nights since the last raidvoidNotify raid manager of a passing through raid.voidsetRaidNextNight(IRaiderManager.RaidSettings raidSettings) Set if raiders will raid tonight.voidsetSpiesEnabled(boolean enabled) Sets whether spies are enabledbooleanChecks if raiders will raid tonight.voidwrite(net.minecraft.nbt.CompoundTag compound) Writes the raid manager to nbt
-
Field Details
-
SPAWN_MODIFIER
public static final double SPAWN_MODIFIERSpawn modifier to decrease the spawn-rate.- See Also:
-
MIN_REQUIRED_RAIDLEVEL
public static final int MIN_REQUIRED_RAIDLEVELMin required raidlevel- See Also:
-
-
Constructor Details
-
RaidManager
Creates the RaidManager for a colony.- Parameters:
colony- the colony.
-
-
Method Details
-
canHaveRaiderEvents
public boolean canHaveRaiderEvents()Description copied from interface:IRaiderManagerChecks if the raider manager can have raider events.- Specified by:
canHaveRaiderEventsin interfaceIRaiderManager- Returns:
- true if so.
-
willRaidTonight
public boolean willRaidTonight()Description copied from interface:IRaiderManagerChecks if raiders will raid tonight.- Specified by:
willRaidTonightin interfaceIRaiderManager- Returns:
- true if so.
-
setCanHaveRaiderEvents
public void setCanHaveRaiderEvents(boolean canHave) Description copied from interface:IRaiderManagerSet that the manager can receive raider events.- Specified by:
setCanHaveRaiderEventsin interfaceIRaiderManager- Parameters:
canHave- true or false.
-
setRaidNextNight
Description copied from interface:IRaiderManagerSet if raiders will raid tonight.- Specified by:
setRaidNextNightin interfaceIRaiderManager- Parameters:
raidSettings- the settings for the next raid, or null to stop the next raid.
-
areSpiesEnabled
public boolean areSpiesEnabled()Description copied from interface:IRaiderManagerReturns whether spies are enabled- Specified by:
areSpiesEnabledin interfaceIRaiderManager- Returns:
- true if enabled.
-
setSpiesEnabled
public void setSpiesEnabled(boolean enabled) Description copied from interface:IRaiderManagerSets whether spies are enabled- Specified by:
setSpiesEnabledin interfaceIRaiderManager- Parameters:
enabled- true if enabled.
-
raiderEvent
public IRaiderManager.RaidSpawnResult raiderEvent(@NotNull @NotNull IRaiderManager.RaidSettings raidSettings) Description copied from interface:IRaiderManagerTrigger a specific type of raid on a colony.- Specified by:
raiderEventin interfaceIRaiderManager- 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:
calculateSpawnLocationin interfaceIRaiderManager- 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
Description copied from interface:IRaiderManagerGetter for the last spawn points.- Specified by:
getLastSpawnPointsin interfaceIRaiderManager- Returns:
- a copy of the list
-
calculateRaiderAmount
public int calculateRaiderAmount(int raidLevel) Returns the colonies barbarian level- Specified by:
calculateRaiderAmountin interfaceIRaiderManager- Parameters:
raidLevel- the colonies raidlevel- Returns:
- the amount of barbarians.
-
isRaided
public boolean isRaided()Description copied from interface:IRaiderManagerWhether the colony is currently raided.- Specified by:
isRaidedin interfaceIRaiderManager- Returns:
- true if so.
-
onNightFall
public void onNightFall()Description copied from interface:IRaiderManagerCalled on nightfall.- Specified by:
onNightFallin interfaceIRaiderManager
-
getNightsSinceLastRaid
public int getNightsSinceLastRaid()Description copied from interface:IRaiderManagerReturns the amount of nights since the last raid- Specified by:
getNightsSinceLastRaidin interfaceIRaiderManager- Returns:
- the number of nights.
-
setNightsSinceLastRaid
public void setNightsSinceLastRaid(int nightsSinceLastRaid) Description copied from interface:IRaiderManagerSets the amount of nights since the last raid- Specified by:
setNightsSinceLastRaidin interfaceIRaiderManager- Parameters:
nightsSinceLastRaid- the nights to set.
-
canRaid
public boolean canRaid()Description copied from interface:IRaiderManagerWhether the colony can be raided.- Specified by:
canRaidin interfaceIRaiderManager- Returns:
- true if possible.
-
getColonyRaidLevel
public int getColonyRaidLevel()Takes a colony and spits out that colony's RaidLevel.- Specified by:
getColonyRaidLevelin interfaceIRaiderManager- Returns:
- an int describing the raid level
-
getRandomBuilding
@NotNull public @NotNull net.minecraft.core.BlockPos getRandomBuilding()Description copied from interface:IRaiderManagerReturns a random building for raiders to go to, groups up 3 raiders to the same position.- Specified by:
getRandomBuildingin interfaceIRaiderManager- Returns:
- a random building.
-
getRaidDifficultyModifier
public double getRaidDifficultyModifier()Description copied from interface:IRaiderManagerGets the difficulty modifier for raids, default difficulty is 1.0- Specified by:
getRaidDifficultyModifierin interfaceIRaiderManager- Returns:
- difficulty
-
onLostCitizen
Description copied from interface:IRaiderManagerCalled on loosing a citizen, to record deaths during raids- Specified by:
onLostCitizenin interfaceIRaiderManager- Parameters:
citizen- that died
-
write
public void write(net.minecraft.nbt.CompoundTag compound) Description copied from interface:IRaiderManagerWrites the raid manager to nbt- Specified by:
writein interfaceIRaiderManager- Parameters:
compound- to write to
-
read
public void read(net.minecraft.nbt.CompoundTag compound) Description copied from interface:IRaiderManagerReads the raid manager form nbt- Specified by:
readin interfaceIRaiderManager- Parameters:
compound- to read from
-
getLostCitizen
public int getLostCitizen()Description copied from interface:IRaiderManagerGets the amount of citizens lost in a raid.- Specified by:
getLostCitizenin interfaceIRaiderManager- Returns:
- amount
-
onRaiderDeath
Description copied from interface:IRaiderManagerCalled when a raider mob dies- Specified by:
onRaiderDeathin interfaceIRaiderManager
-
onRaidEventFinished
- Specified by:
onRaidEventFinishedin interfaceIRaiderManager
-
getLastRaid
List of raid histories- Returns:
-
setPassThroughRaid
public void setPassThroughRaid()Description copied from interface:IRaiderManagerNotify raid manager of a passing through raid.- Specified by:
setPassThroughRaidin interfaceIRaiderManager
-
getAllRaids
Gets all raid histories- Returns:
-