Commits

DerFrZocker authored and md_5 committed 93061706ebc
SPIGOT-7045: Ocelots never spawn with babies with spawn reason OCELOT_BABY
No tags

nms-patches/net/minecraft/world/level/SpawnerCreature.patch

Modified
34 34 - if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategory(enumcreaturetype, chunk.getPos())) {
35 35 + if (!spawnThisTick || limit == 0) {
36 36 + continue;
37 37 + }
38 38 +
39 39 + if ((flag || !enumcreaturetype.isFriendly()) && (flag1 || enumcreaturetype.isFriendly()) && (flag2 || !enumcreaturetype.isPersistent()) && spawnercreature_d.canSpawnForCategory(enumcreaturetype, chunk.getPos(), limit)) {
40 40 + // CraftBukkit end
41 41 Objects.requireNonNull(spawnercreature_d);
42 42 SpawnerCreature.c spawnercreature_c = spawnercreature_d::canSpawn;
43 43
44 -@@ -200,10 +222,14 @@
44 +@@ -200,10 +222,15 @@
45 45 entityinsentient.moveTo(d0, (double) i, d1, worldserver.random.nextFloat() * 360.0F, 0.0F);
46 46 if (isValidPositionForMob(worldserver, entityinsentient, d2)) {
47 47 groupdataentity = entityinsentient.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.NATURAL, groupdataentity, (NBTTagCompound) null);
48 48 - ++j;
49 49 - ++k1;
50 50 - worldserver.addFreshEntityWithPassengers(entityinsentient);
51 51 - spawnercreature_a.run(entityinsentient, ichunkaccess);
52 52 + // CraftBukkit start
53 -+ worldserver.addFreshEntityWithPassengers(entityinsentient, SpawnReason.NATURAL);
53 ++ // SPIGOT-7045: Give ocelot babies back their special spawn reason. Note: This is the only modification required as ocelots count as monsters which means they only spawn during normal chunk ticking and do not spawn during chunk generation as starter mobs.
54 ++ worldserver.addFreshEntityWithPassengers(entityinsentient, (entityinsentient instanceof net.minecraft.world.entity.animal.EntityOcelot && !((org.bukkit.entity.Ageable) entityinsentient.getBukkitEntity()).isAdult()) ? SpawnReason.OCELOT_BABY : SpawnReason.NATURAL);
54 55 + if (!entityinsentient.isRemoved()) {
55 56 + ++j;
56 57 + ++k1;
57 58 + spawnercreature_a.run(entityinsentient, ichunkaccess);
58 59 + }
59 60 + // CraftBukkit end
60 61 if (j >= entityinsentient.getMaxSpawnClusterSize()) {
61 62 return;
62 63 }
63 -@@ -384,7 +410,7 @@
64 +@@ -384,7 +411,7 @@
64 65
65 66 if (entityinsentient.checkSpawnRules(worldaccess, EnumMobSpawn.CHUNK_GENERATION) && entityinsentient.checkSpawnObstruction(worldaccess)) {
66 67 groupdataentity = entityinsentient.finalizeSpawn(worldaccess, worldaccess.getCurrentDifficultyAt(entityinsentient.blockPosition()), EnumMobSpawn.CHUNK_GENERATION, groupdataentity, (NBTTagCompound) null);
67 68 - worldaccess.addFreshEntityWithPassengers(entityinsentient);
68 69 + worldaccess.addFreshEntityWithPassengers(entityinsentient, SpawnReason.CHUNK_GEN); // CraftBukkit
69 70 flag = true;
70 71 }
71 72 }
72 -@@ -505,8 +531,10 @@
73 +@@ -505,8 +532,10 @@
73 74 return this.unmodifiableMobCategoryCounts;
74 75 }
75 76
76 77 - boolean canSpawnForCategory(EnumCreatureType enumcreaturetype, ChunkCoordIntPair chunkcoordintpair) {
77 78 - int i = enumcreaturetype.getMaxInstancesPerChunk() * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER;
78 79 + // CraftBukkit start
79 80 + boolean canSpawnForCategory(EnumCreatureType enumcreaturetype, ChunkCoordIntPair chunkcoordintpair, int limit) {
80 81 + int i = limit * this.spawnableChunkCount / SpawnerCreature.MAGIC_NUMBER;
81 82 + // CraftBukkit end
82 83

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut