Remove unnecessary changes

This commit is contained in:
Alexandra-Myers 2026-03-11 00:07:39 -04:00
parent ae138caaf2
commit e0edd377ce
7 changed files with 24 additions and 78 deletions

View file

@ -222,25 +222,7 @@ int Biome::getSkyColor(float temp)
vector<Biome::MobSpawnerData *> *Biome::getMobs(MobCategory *category)
{
if (category == MobCategory::monster) return &enemies;
if (category == MobCategory::creature)
{
if (app.GetGameHostOption(eGameHostOption_NoMobCap))
{
// Only input into this if necessary, this should be after all others are set up for this biome as well
size_t combinedSize = friendlies.size() + friendlies_chicken.size() + friendlies_wolf.size() + friendlies_mushroomcow.size();
if (all_friendlies.empty() && combinedSize > 0) {
// If empty, reserve the combined size of all mob spawner data
all_friendlies.reserve(combinedSize);
// Combine each vector into all_friendlies
all_friendlies.insert(all_friendlies.end(), friendlies.begin(), friendlies.end());
all_friendlies.insert(all_friendlies.end(), friendlies_chicken.begin(), friendlies_chicken.end());
all_friendlies.insert(all_friendlies.end(), friendlies_wolf.begin(), friendlies_wolf.end());
all_friendlies.insert(all_friendlies.end(), friendlies_mushroomcow.begin(), friendlies_mushroomcow.end());
}
return &all_friendlies; // Use combined vector when using Java logic
}
return &friendlies;
}
if (category == MobCategory::creature) return &friendlies;
if (category == MobCategory::waterCreature) return &waterFriendlies;
if (category == MobCategory::creature_chicken) return &friendlies_chicken;
if (category == MobCategory::creature_wolf) return &friendlies_wolf;

View file

@ -82,7 +82,6 @@ public:
protected:
vector<MobSpawnerData *> enemies;
vector<MobSpawnerData *> all_friendlies; // Added to not have to recombine with other groups every time spawner data is used
vector<MobSpawnerData *> friendlies;
vector<MobSpawnerData *> waterFriendlies;
vector<MobSpawnerData *> friendlies_chicken;

View file

@ -4717,10 +4717,6 @@ bool Level::canCreateMore(eINSTANCEOF type, ESPAWN_TYPE spawnType)
count = countInstanceOf( eTYPE_WOLF, true);
max = MobCategory::max_wolves_with_spawn_egg;
break;
case eTYPE_MUSHROOMCOW:
count = countInstanceOf( eTYPE_MUSHROOMCOW, true);
max = MobCategory::max_mushroomcows_with_spawn_egg;
break;
case eTYPE_SQUID:
count = countInstanceOf( eTYPE_SQUID, true);
max = MobCategory::max_squids_with_spawn_egg;
@ -4783,10 +4779,6 @@ bool Level::canCreateMore(eINSTANCEOF type, ESPAWN_TYPE spawnType)
count = countInstanceOf( eTYPE_WOLF, true);
max = MobCategory::max_wolves_with_breeding;
break;
case eTYPE_MUSHROOMCOW:
count = countInstanceOf( eTYPE_MUSHROOMCOW, true);
max = MobCategory::max_mushroomcows_with_breeding;
break;
default:
if((type & eTYPE_ANIMALS_SPAWN_LIMIT_CHECK) == eTYPE_ANIMALS_SPAWN_LIMIT_CHECK)
{

View file

@ -43,58 +43,39 @@ MobCategoryArray MobCategory::values = MobCategoryArray(7);
void MobCategory::staticCtor()
{
// 4J - adjusted the max levels here for the xbox version, which now represent the max levels in the whole world
monster = new MobCategory(70, Material::air, false, false, eTYPE_MONSTER, false);
// Raised these to be identical to base LCE
creature = new MobCategory(50, Material::air, true, true, eTYPE_ANIMALS_SPAWN_LIMIT_CHECK, eTYPE_ANIMAL, false);
ambient = new MobCategory(20, Material::air, true, false, eTYPE_AMBIENT, false),
waterCreature = new MobCategory(5, Material::water, true, false, eTYPE_WATERANIMAL, false);
// Use pointers to modifiable fields, in future can become modifiable
monster = new MobCategory(&max_natural_monsters, Material::air, false, false, eTYPE_MONSTER, false);
creature = new MobCategory(&max_natural_animals, Material::air, true, true, eTYPE_ANIMALS_SPAWN_LIMIT_CHECK, false);
ambient = new MobCategory(&max_natural_ambient, Material::air, true, false, eTYPE_AMBIENT, false),
waterCreature = new MobCategory(&max_natural_squid, Material::water, true, false, eTYPE_WATERANIMAL, false);
values[0] = monster;
values[1] = creature;
values[2] = ambient;
values[3] = waterCreature;
// 4J - added 2 new categories to give us better control over spawning wolves & chickens
creature_wolf = new MobCategory(3, Material::air, true, true, eTYPE_WOLF, true);
creature_chicken = new MobCategory(2, Material::air, true, true, eTYPE_CHICKEN, true);
creature_mushroomcow = new MobCategory(2, Material::air, true, true, eTYPE_MUSHROOMCOW, true);
creature_wolf = new MobCategory(&max_natural_wolves, Material::air, true, true, eTYPE_WOLF, true);
creature_chicken = new MobCategory(&max_natural_chickens, Material::air, true, true, eTYPE_CHICKEN, true);
creature_mushroomcow = new MobCategory(&max_natural_mushroomcows, Material::air, true, true, eTYPE_MUSHROOMCOW, true);
values[4] = creature_wolf;
values[5] = creature_chicken;
values[6] = creature_mushroomcow;
monster->m_maxPerLevel = max_natural_monsters;
creature->m_maxPerLevel = max_natural_animals;
ambient->m_maxPerLevel = max_natural_ambient;
waterCreature->m_maxPerLevel = max_natural_squid;
creature_wolf->m_maxPerLevel = max_natural_wolves;
creature_chicken->m_maxPerLevel = max_natural_chickens;
creature_mushroomcow->m_maxPerLevel = max_natural_mushroomcows;
}
MobCategory::MobCategory(int maxVar, Material *spawnPositionMaterial, bool isFriendly, bool isPersistent, eINSTANCEOF eBase, bool isSingleType)
: m_max(maxVar), spawnPositionMaterial(spawnPositionMaterial), m_isFriendly(isFriendly), m_isPersistent(isPersistent), m_eBase(eBase), m_eJavaBase(eBase), m_isSingleType(isSingleType)
{
}
MobCategory::MobCategory(int maxVar, Material *spawnPositionMaterial, bool isFriendly, bool isPersistent, eINSTANCEOF eBase, eINSTANCEOF eJavaBase, bool isSingleType)
: m_max(maxVar), spawnPositionMaterial(spawnPositionMaterial), m_isFriendly(isFriendly), m_isPersistent(isPersistent), m_eBase(eBase), m_eJavaBase(eJavaBase), m_isSingleType(isSingleType)
MobCategory::MobCategory(int *maxVar, Material *spawnPositionMaterial, bool isFriendly, bool isPersistent, eINSTANCEOF eBase, bool isSingleType)
: m_max(maxVar), spawnPositionMaterial(spawnPositionMaterial), m_isFriendly(isFriendly), m_isPersistent(isPersistent), m_eBase(eBase), m_isSingleType(isSingleType)
{
}
// 4J - added
const eINSTANCEOF MobCategory::getEnumBaseClass()
{
if (app.GetGameHostOption(eGameHostOption_NoMobCap)) return m_eJavaBase;
return m_eBase;
}
int MobCategory::getMaxInstancesPerChunk()
{
return m_max;
}
int MobCategory::getMaxInstancesPerLevel() // 4J added
{
return m_maxPerLevel;
return *m_max;
}
Material *MobCategory::getSpawnPositionMaterial()

View file

@ -8,22 +8,22 @@ class MobCategory
public:
// 4J - putting constants for xbox spawning in one place to tidy things up a bit - all numbers are per level
static int max_natural_monsters; // Max number of enemies (skeleton, zombie, creeper etc) that the mob spawner will produce
static int max_natural_animals; // Max number of animals (cows, sheep, pigs) that the mob spawner will produce
static int max_natural_ambient; // Ambient mobs
static int max_natural_animals; // Max number of animals (cows, sheep, pigs) that the mob spawner will produce
static int max_natural_ambient; // Ambient mobs
static int max_natural_squid; // Max number of squid that the mob spawner will produce
static int max_natural_chickens; // Max number of chickens that the mob spawner will produce
static int max_natural_wolves; // Max number of wolves that the mob spawner will produce
static int max_natural_wolves; // Max number of wolves that the mob spawner will produce
static int max_natural_mushroomcows; // Max number of mushroom cows that the mob spawner will produce
static int max_snow_golems; // Max number of snow golems that can be created by placing blocks - 4J-PB increased limit due to player requests
static int max_iron_golems; // Max number of iron golems that can be created by placing blocks - 4J-PB increased limit due to player requests
static int max_bosses; // Max number of bosses (enderdragon/wither)
static int max_snow_golems; // Max number of snow golems that can be created by placing blocks - 4J-PB increased limit due to player requests
static int max_iron_golems; // Max number of iron golems that can be created by placing blocks - 4J-PB increased limit due to player requests
static int max_bosses; // Max number of bosses (enderdragon/wither)
static int max_animals_with_breeding; // Max number of animals that we can produce (in total), when breeding
static int max_chickens_with_breeding; // Max number of chickens that we can produce (in total), when breeding/hatching
static int max_mushroomcows_with_breeding; // Max number of mushroom cows that we can produce (in total), when breeding
static int max_wolves_with_breeding; // Max number of wolves that we can produce (in total), when breeding
static int max_villagers_with_breeding; // Max number of villagers that we can produce (in total), when breeding
static int max_villagers_with_breeding; // Max number of villagers that we can produce (in total), when breeding
static int max_animals_with_spawn_egg; // Max number of animals that we can produce (in total), when using spawn eggs
static int max_chickens_with_spawn_egg; // Max number of chickens that we can produce (in total), when using spawn eggs
@ -64,27 +64,21 @@ public:
private:
const int m_max;
int m_maxPerLevel = 0;
// Use pointers to allow for this to be changed indirectly whilst staying a const
const int *m_max;
const Material *spawnPositionMaterial;
const bool m_isFriendly;
const bool m_isPersistent;
const bool m_isSingleType; // 4J Added
const eINSTANCEOF m_eBase; // 4J added
// Added for animals so that wolves, mushroomcows, and chickens can be included in the category count.
// Only used when mob cap is unlimited, done to ensure the wolves and chickens can spawn properly.
// When using the shorter constructor, this will be set to m_eBase.
const eINSTANCEOF m_eJavaBase;
MobCategory(int maxVar, Material *spawnPositionMaterial, bool isFriendly, bool isPersistent, eINSTANCEOF eBase, bool isSingleType);
// Additional constructor, allows specifying the enum to use if mob cap is unlimited
MobCategory(int maxVar, Material * spawnPositionMaterial, bool isFriendly, bool isPersistent, eINSTANCEOF eBase, eINSTANCEOF eJavaBase, bool isSingleType);
MobCategory(int *maxVar, Material *spawnPositionMaterial, bool isFriendly, bool isPersistent, eINSTANCEOF eBase, bool isSingleType);
public:
const type_info getBaseClass();
const eINSTANCEOF getEnumBaseClass(); // 4J added
int getMaxInstancesPerChunk();
int getMaxInstancesPerLevel(); // 4J added
// int getMaxInstancesPerLevel(); 4J added ~ Removed as it has been merged with getMaxInstancesPerChunk()
Material *getSpawnPositionMaterial();
bool isFriendly();
bool isSingleType();

View file

@ -210,15 +210,13 @@ const int MobSpawner::tick(ServerLevel *level, bool spawnEnemies, bool spawnFrie
}
// Use variable to not repeat checks
int maxInstances = mobCategory->getMaxInstancesPerLevel();
int maxInstances = mobCategory->getMaxInstancesPerChunk(); // Merged in values from getMaxInstancesPerLevel(), so changed to use getMaxInstancesPerChunk()
// Check for if the mob cap is "off" (works as Java does, scaled by chunk count)
bool usesChunkLimit = app.GetGameHostOption(eGameHostOption_NoMobCap);
if (usesChunkLimit)
{
// Use Java logic for the max count instead, accounting for chunks polled and the magic number.
maxInstances = mobCategory->getMaxInstancesPerChunk() * chunksToPoll.size() / MAGIC_NUMBER;
// Cancel spawning under extra categories, with this option they should be included in creature
if (i > 3) continue;
}
// 4J - this is now quite different to the java version. We just have global max counts for the level whereas the original has a max per chunk that