mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-08-20 09:57:09 +00:00
feat: configurable mob spawn caps via server.properties
This commit is contained in:
parent
c297b26f36
commit
ffdad03aca
|
|
@ -888,6 +888,14 @@ ServerPropertiesConfig LoadServerPropertiesConfig()
|
||||||
config.hardcore = ReadNormalizedBoolProperty(&merged, "hardcore", false, &shouldWrite);
|
config.hardcore = ReadNormalizedBoolProperty(&merged, "hardcore", false, &shouldWrite);
|
||||||
config.hardcoreBanIp = ReadNormalizedBoolProperty(&merged, "hardcore-ban-ip", false, &shouldWrite);
|
config.hardcoreBanIp = ReadNormalizedBoolProperty(&merged, "hardcore-ban-ip", false, &shouldWrite);
|
||||||
|
|
||||||
|
config.maxMonsters = ReadNormalizedIntProperty(&merged, "max-monsters", 50, 0, 1000, &shouldWrite);
|
||||||
|
config.maxAnimals = ReadNormalizedIntProperty(&merged, "max-animals", 50, 0, 1000, &shouldWrite);
|
||||||
|
config.maxAmbient = ReadNormalizedIntProperty(&merged, "max-ambient", 20, 0, 1000, &shouldWrite);
|
||||||
|
config.maxWaterAnimals = ReadNormalizedIntProperty(&merged, "max-water-animals", 5, 0, 1000, &shouldWrite);
|
||||||
|
config.maxWolves = ReadNormalizedIntProperty(&merged, "max-wolves", 8, 0, 1000, &shouldWrite);
|
||||||
|
config.maxChickens = ReadNormalizedIntProperty(&merged, "max-chickens", 8, 0, 1000, &shouldWrite);
|
||||||
|
config.maxMushroomCows = ReadNormalizedIntProperty(&merged, "max-mushroom-cows", 2, 0, 1000, &shouldWrite);
|
||||||
|
|
||||||
config.maxBuildHeight = ReadNormalizedIntProperty(&merged, "max-build-height", 256, 64, 256, &shouldWrite);
|
config.maxBuildHeight = ReadNormalizedIntProperty(&merged, "max-build-height", 256, 64, 256, &shouldWrite);
|
||||||
config.motd = ReadNormalizedStringProperty(&merged, "motd", "A Minecraft Server", 255, &shouldWrite);
|
config.motd = ReadNormalizedStringProperty(&merged, "motd", "A Minecraft Server", 255, &shouldWrite);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,21 @@ namespace ServerRuntime
|
||||||
/** `hardcore-ban-ip` — whether hardcore death bans include IP bans */
|
/** `hardcore-ban-ip` — whether hardcore death bans include IP bans */
|
||||||
bool hardcoreBanIp;
|
bool hardcoreBanIp;
|
||||||
|
|
||||||
|
/** `max-monsters` natural spawn cap for monsters (zombies, skeletons, creepers, etc.) */
|
||||||
|
int maxMonsters;
|
||||||
|
/** `max-animals` natural spawn cap for animals (cows, sheep, pigs) */
|
||||||
|
int maxAnimals;
|
||||||
|
/** `max-ambient` natural spawn cap for ambient mobs (bats) */
|
||||||
|
int maxAmbient;
|
||||||
|
/** `max-water-animals` natural spawn cap for water mobs (squid) */
|
||||||
|
int maxWaterAnimals;
|
||||||
|
/** `max-wolves` natural spawn cap for wolves */
|
||||||
|
int maxWolves;
|
||||||
|
/** `max-chickens` natural spawn cap for chickens */
|
||||||
|
int maxChickens;
|
||||||
|
/** `max-mushroom-cows` natural spawn cap for mooshrooms */
|
||||||
|
int maxMushroomCows;
|
||||||
|
|
||||||
/** security settings */
|
/** security settings */
|
||||||
/** `hide-player-list-prelogin` — strip XUIDs from PreLoginPacket response */
|
/** `hide-player-list-prelogin` — strip XUIDs from PreLoginPacket response */
|
||||||
bool hidePlayerListPreLogin;
|
bool hidePlayerListPreLogin;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include "../../Minecraft.World/ConsoleSaveFileOriginal.h"
|
#include "../../Minecraft.World/ConsoleSaveFileOriginal.h"
|
||||||
#include "../../Minecraft.World/net.minecraft.world.level.tile.h"
|
#include "../../Minecraft.World/net.minecraft.world.level.tile.h"
|
||||||
#include "../../Minecraft.World/Random.h"
|
#include "../../Minecraft.World/Random.h"
|
||||||
|
#include "../../Minecraft.World/MobCategory.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
@ -557,10 +558,18 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
LogError("startup", "Minecraft initialization failed.");
|
LogError("startup", "Minecraft initialization failed.");
|
||||||
CleanupDevice();
|
CleanupDevice();
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MobCategory::monster->setMaxInstancesPerLevel(serverProperties.maxMonsters);
|
||||||
|
MobCategory::creature->setMaxInstancesPerLevel(serverProperties.maxAnimals);
|
||||||
|
MobCategory::ambient->setMaxInstancesPerLevel(serverProperties.maxAmbient);
|
||||||
|
MobCategory::waterCreature->setMaxInstancesPerLevel(serverProperties.maxWaterAnimals);
|
||||||
|
MobCategory::creature_wolf->setMaxInstancesPerLevel(serverProperties.maxWolves);
|
||||||
|
MobCategory::creature_chicken->setMaxInstancesPerLevel(serverProperties.maxChickens);
|
||||||
|
MobCategory::creature_mushroomcow->setMaxInstancesPerLevel(serverProperties.maxMushroomCows);
|
||||||
|
|
||||||
app.InitGameSettings();
|
app.InitGameSettings();
|
||||||
|
|
||||||
MinecraftServer::resetFlags();
|
MinecraftServer::resetFlags();
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,11 @@ int MobCategory::getMaxInstancesPerLevel() // 4J added
|
||||||
return m_maxPerLevel;
|
return m_maxPerLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MobCategory::setMaxInstancesPerLevel(int max)
|
||||||
|
{
|
||||||
|
m_maxPerLevel = max;
|
||||||
|
}
|
||||||
|
|
||||||
Material *MobCategory::getSpawnPositionMaterial()
|
Material *MobCategory::getSpawnPositionMaterial()
|
||||||
{
|
{
|
||||||
return (Material *) spawnPositionMaterial;
|
return (Material *) spawnPositionMaterial;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const int m_max;
|
const int m_max;
|
||||||
const int m_maxPerLevel;
|
int m_maxPerLevel;
|
||||||
const Material *spawnPositionMaterial;
|
const Material *spawnPositionMaterial;
|
||||||
const bool m_isFriendly;
|
const bool m_isFriendly;
|
||||||
const bool m_isPersistent;
|
const bool m_isPersistent;
|
||||||
|
|
@ -79,6 +79,7 @@ public:
|
||||||
const eINSTANCEOF getEnumBaseClass(); // 4J added
|
const eINSTANCEOF getEnumBaseClass(); // 4J added
|
||||||
int getMaxInstancesPerChunk();
|
int getMaxInstancesPerChunk();
|
||||||
int getMaxInstancesPerLevel(); // 4J added
|
int getMaxInstancesPerLevel(); // 4J added
|
||||||
|
void setMaxInstancesPerLevel(int max); // 4J added
|
||||||
Material *getSpawnPositionMaterial();
|
Material *getSpawnPositionMaterial();
|
||||||
bool isFriendly();
|
bool isFriendly();
|
||||||
bool isSingleType();
|
bool isSingleType();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue