20w18a-1
This commit is contained in:
1 parent
98f514ffce
commit
f04888406d
10 files changed
+108
-104
No files matched your search
@@ -31,8 +31,6 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
||||
{
|
||||
@Shadow @Final private ServerWorld world;
|
||||
|
||||
@Shadow @Final private static int CHUNKS_ELIGIBLE_FOR_SPAWNING;
|
||||
|
||||
@Shadow @Final private ChunkTicketManager ticketManager;
|
||||
|
||||
@Override // shared between scarpet and spawnChunks setting
|
||||
@@ -41,33 +39,17 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
||||
return ticketManager;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "tickChunks",
|
||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;entryIterator()Ljava/lang/Iterable;",
|
||||
shift = At.Shift.AFTER,
|
||||
ordinal = 0
|
||||
|
||||
@Redirect(method = "tickChunks", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/world/ChunkTicketManager;getLevelCount()I"
|
||||
))
|
||||
//this runs once per world spawning cycle. Allows to grab mob counts and count spawn ticks
|
||||
private void grabMobcaps(CallbackInfo ci,
|
||||
long long_1,
|
||||
long long_2,
|
||||
class_5217 levelProperties_1,
|
||||
boolean boolean_1,
|
||||
boolean boolean_2,
|
||||
int int_1,
|
||||
boolean boolean_3,
|
||||
int int_2,
|
||||
EntityCategory[] entityCategorys_1,
|
||||
Object2IntMap object2IntMap_1)
|
||||
private int setupTracking(ChunkTicketManager chunkTicketManager)
|
||||
{
|
||||
int j = chunkTicketManager.getLevelCount();
|
||||
DimensionType dim = this.world.dimension.getType();
|
||||
//((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
|
||||
SpawnReporter.mobCounts.put(dim, (Object2IntMap<EntityCategory>)object2IntMap_1);
|
||||
SpawnReporter.chunkCounts.put(dim, int_2);
|
||||
SpawnReporter.chunkCounts.put(dim, j);
|
||||
|
||||
if (SpawnReporter.track_spawns > 0L)
|
||||
{
|
||||
@@ -82,67 +64,9 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
||||
SpawnReporter.spawn_tries.get(cat));
|
||||
}
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(method = "method_20801", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;)V"
|
||||
))
|
||||
// inject our repeat of spawns if more spawn ticks per tick are chosen.
|
||||
private void spawnMultipleTimes(EntityCategory entityCategory_1, ServerWorld world_1, WorldChunk worldChunk_1)
|
||||
{
|
||||
for (int i = 0; i < SpawnReporter.spawn_tries.get(entityCategory_1); i++)
|
||||
{
|
||||
SpawnHelper.spawnEntitiesInChunk(entityCategory_1, world_1, worldChunk_1);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnresolvedMixinReference")
|
||||
@Redirect(method = "method_20801", at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/entity/EntityCategory;getSpawnCap()I"
|
||||
))
|
||||
// allows to change mobcaps and captures each category try per dimension before it fails due to full mobcaps.
|
||||
private int getNewMobcaps(EntityCategory entityCategory)
|
||||
{
|
||||
DimensionType dim = this.world.dimension.getType();
|
||||
int newCap = (int) ((double)entityCategory.getSpawnCap()*(Math.pow(2.0,(SpawnReporter.mobcap_exponent/4))));
|
||||
if (SpawnReporter.track_spawns > 0L)
|
||||
{
|
||||
int int_2 = SpawnReporter.chunkCounts.get(dim); // eligible chunks for spawning
|
||||
int int_3 = newCap * int_2 / CHUNKS_ELIGIBLE_FOR_SPAWNING; //current spawning limits
|
||||
int mobCount = SpawnReporter.mobCounts.get(dim).getInt(entityCategory);
|
||||
|
||||
if (SpawnReporter.track_spawns > 0L && !SpawnReporter.first_chunk_marker.contains(entityCategory))
|
||||
{
|
||||
SpawnReporter.first_chunk_marker.add(entityCategory);
|
||||
//first chunk with spawn eligibility for that category
|
||||
Pair key = Pair.of(dim, entityCategory);
|
||||
|
||||
|
||||
int spawnTries = SpawnReporter.spawn_tries.get(entityCategory);
|
||||
|
||||
SpawnReporter.spawn_attempts.put(key,
|
||||
SpawnReporter.spawn_attempts.get(key) + spawnTries);
|
||||
|
||||
SpawnReporter.spawn_cap_count.put(key,
|
||||
SpawnReporter.spawn_cap_count.get(key) + mobCount);
|
||||
}
|
||||
|
||||
if (mobCount <= int_3 || SpawnReporter.mock_spawns)
|
||||
{
|
||||
//place 0 to indicate there were spawn attempts for a category
|
||||
//if (entityCategory != EntityCategory.CREATURE || world.getServer().getTicks() % 400 == 0)
|
||||
// this will only be called once every 400 ticks anyways
|
||||
SpawnReporter.local_spawns.putIfAbsent(entityCategory, 0L);
|
||||
|
||||
//else
|
||||
//full mobcaps - and key in local_spawns will be missing
|
||||
}
|
||||
}
|
||||
return SpawnReporter.mock_spawns?Integer.MAX_VALUE:newCap;
|
||||
}
|
||||
|
||||
@Inject(method = "tickChunks", at = @At("RETURN"))
|
||||
private void onFinishSpawnWorldCycle(CallbackInfo ci)
|
||||
|
||||
Reference in new issue
Block a user