20w18a-1
This commit is contained in:
1 parent
98f514ffce
commit
f04888406d
10 files changed
+108
-104
No files matched your search
+2
-2
@@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
# or better: https://modmuss50.me/fabric.html
|
# or better: https://modmuss50.me/fabric.html
|
||||||
minecraft_version=20w17a
|
minecraft_version=20w18a
|
||||||
yarn_mappings=20w17a+build.7
|
yarn_mappings=20w18a+build.1
|
||||||
loader_version=0.8.2+build.194
|
loader_version=0.8.2+build.194
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ public class SpawnCommand
|
|||||||
|
|
||||||
private static int generalMobcaps(ServerCommandSource source)
|
private static int generalMobcaps(ServerCommandSource source)
|
||||||
{
|
{
|
||||||
Messenger.send(source, SpawnReporter.printMobcapsForDimension(source.getWorld().getDimension().getType(), true));
|
Messenger.send(source, SpawnReporter.printMobcapsForDimension(source.getWorld(), true));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ public class SpawnCommand
|
|||||||
|
|
||||||
private static int mobcapsForDimension(ServerCommandSource source, DimensionType dim)
|
private static int mobcapsForDimension(ServerCommandSource source, DimensionType dim)
|
||||||
{
|
{
|
||||||
Messenger.send(source, SpawnReporter.printMobcapsForDimension(dim, true));
|
Messenger.send(source, SpawnReporter.printMobcapsForDimension(source.getWorld(), true));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ import static net.minecraft.block.RedstoneWireBlock.POWER;
|
|||||||
|
|
||||||
@Mixin(RedstoneWireBlock.class)
|
@Mixin(RedstoneWireBlock.class)
|
||||||
public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterface {
|
public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterface {
|
||||||
// =
|
/*
|
||||||
|
|
||||||
|
needs reworking
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
private boolean wiresGivePower;
|
private boolean wiresGivePower;
|
||||||
@@ -72,7 +74,7 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author theosib, soykaf, gnembon
|
* @author theosib, soykaf, gnembon
|
||||||
*/
|
*
|
||||||
@Inject(method = "updateLogic", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "updateLogic", at = @At("HEAD"), cancellable = true)
|
||||||
private void updateLogicAlternative(World world, BlockPos pos, BlockState state, CallbackInfoReturnable<BlockState> cir)
|
private void updateLogicAlternative(World world, BlockPos pos, BlockState state, CallbackInfoReturnable<BlockState> cir)
|
||||||
{
|
{
|
||||||
@@ -164,4 +166,6 @@ public abstract class RedstoneWireBlockMixin implements RedstoneWireBlockInterfa
|
|||||||
boolean boolean_1) {
|
boolean boolean_1) {
|
||||||
return fastUpdate(world_1, blockPos_1, blockState_1, blockPos_3);
|
return fastUpdate(world_1, blockPos_1, blockState_1, blockPos_3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
@@ -31,8 +31,6 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
|||||||
{
|
{
|
||||||
@Shadow @Final private ServerWorld world;
|
@Shadow @Final private ServerWorld world;
|
||||||
|
|
||||||
@Shadow @Final private static int CHUNKS_ELIGIBLE_FOR_SPAWNING;
|
|
||||||
|
|
||||||
@Shadow @Final private ChunkTicketManager ticketManager;
|
@Shadow @Final private ChunkTicketManager ticketManager;
|
||||||
|
|
||||||
@Override // shared between scarpet and spawnChunks setting
|
@Override // shared between scarpet and spawnChunks setting
|
||||||
@@ -41,33 +39,17 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
|||||||
return ticketManager;
|
return ticketManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(
|
@Redirect(method = "tickChunks", at = @At(
|
||||||
method = "tickChunks",
|
value = "INVOKE",
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD,
|
target = "Lnet/minecraft/server/world/ChunkTicketManager;getLevelCount()I"
|
||||||
at = @At(
|
|
||||||
value = "INVOKE",
|
|
||||||
target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;entryIterator()Ljava/lang/Iterable;",
|
|
||||||
shift = At.Shift.AFTER,
|
|
||||||
ordinal = 0
|
|
||||||
|
|
||||||
))
|
))
|
||||||
//this runs once per world spawning cycle. Allows to grab mob counts and count spawn ticks
|
//this runs once per world spawning cycle. Allows to grab mob counts and count spawn ticks
|
||||||
private void grabMobcaps(CallbackInfo ci,
|
private int setupTracking(ChunkTicketManager chunkTicketManager)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
|
int j = chunkTicketManager.getLevelCount();
|
||||||
DimensionType dim = this.world.dimension.getType();
|
DimensionType dim = this.world.dimension.getType();
|
||||||
//((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
|
//((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, j);
|
||||||
SpawnReporter.chunkCounts.put(dim, int_2);
|
|
||||||
|
|
||||||
if (SpawnReporter.track_spawns > 0L)
|
if (SpawnReporter.track_spawns > 0L)
|
||||||
{
|
{
|
||||||
@@ -82,67 +64,9 @@ public abstract class ServerChunkManagerMixin implements ServerChunkManagerInter
|
|||||||
SpawnReporter.spawn_tries.get(cat));
|
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"))
|
@Inject(method = "tickChunks", at = @At("RETURN"))
|
||||||
private void onFinishSpawnWorldCycle(CallbackInfo ci)
|
private void onFinishSpawnWorldCycle(CallbackInfo ci)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.minecraft.item.ItemStack;
|
|||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.stat.Stat;
|
import net.minecraft.stat.Stat;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@@ -24,9 +25,10 @@ import static carpet.script.CarpetEventServer.Event.STATISTICS;
|
|||||||
@Mixin(ServerPlayerEntity.class)
|
@Mixin(ServerPlayerEntity.class)
|
||||||
public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
public abstract class ServerPlayerEntity_scarpetEventMixin extends PlayerEntity
|
||||||
{
|
{
|
||||||
public ServerPlayerEntity_scarpetEventMixin(World world_1, GameProfile gameProfile_1)
|
|
||||||
|
public ServerPlayerEntity_scarpetEventMixin(World world, BlockPos blockPos, GameProfile gameProfile)
|
||||||
{
|
{
|
||||||
super(world_1, gameProfile_1);
|
super(world, blockPos, gameProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Shadow protected abstract void consumeItem();
|
@Shadow protected abstract void consumeItem();
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package carpet.mixins;
|
|||||||
import carpet.helpers.TickSpeed;
|
import carpet.helpers.TickSpeed;
|
||||||
import carpet.utils.CarpetProfiler;
|
import carpet.utils.CarpetProfiler;
|
||||||
import net.minecraft.class_5217;
|
import net.minecraft.class_5217;
|
||||||
|
import net.minecraft.class_5269;
|
||||||
import net.minecraft.entity.raid.RaidManager;
|
import net.minecraft.entity.raid.RaidManager;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.profiler.Profiler;
|
import net.minecraft.util.profiler.Profiler;
|
||||||
@@ -153,10 +154,10 @@ public abstract class ServerWorld_tickMixin extends World
|
|||||||
|
|
||||||
@Redirect(method = "tick", at = @At(
|
@Redirect(method = "tick", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/class_5217;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
|
target = "Lnet/minecraft/class_5269;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
|
||||||
//target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
|
//target = "Lnet/minecraft/world/level/LevelProperties;getGeneratorType()Lnet/minecraft/world/level/LevelGeneratorType;"
|
||||||
))
|
))
|
||||||
private LevelGeneratorType tickPendingBlocks(class_5217 levelProperties)
|
private LevelGeneratorType tickPendingBlocks(class_5269 levelProperties)
|
||||||
{
|
{
|
||||||
if (TickSpeed.process_entities) return levelProperties.getGeneratorType();
|
if (TickSpeed.process_entities) return levelProperties.getGeneratorType();
|
||||||
return LevelGeneratorType.DEBUG_ALL_BLOCK_STATES;
|
return LevelGeneratorType.DEBUG_ALL_BLOCK_STATES;
|
||||||
|
|||||||
@@ -27,7 +27,11 @@ import net.minecraft.world.SpawnHelper;
|
|||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.chunk.Chunk;
|
import net.minecraft.world.chunk.Chunk;
|
||||||
import net.minecraft.world.chunk.WorldChunk;
|
import net.minecraft.world.chunk.WorldChunk;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
@@ -39,6 +43,8 @@ public class SpawnHelperMixin
|
|||||||
|
|
||||||
// in World: private static Map<EntityType, Entity> precookedMobs= new HashMap<>();
|
// in World: private static Map<EntityType, Entity> precookedMobs= new HashMap<>();
|
||||||
|
|
||||||
|
@Shadow @Final private static int field_24392;
|
||||||
|
|
||||||
@Redirect(method = "method_24934", at = @At(
|
@Redirect(method = "method_24934", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/world/ServerWorld;doesNotCollide(Lnet/minecraft/util/math/Box;)Z"
|
target = "Lnet/minecraft/server/world/ServerWorld;doesNotCollide(Lnet/minecraft/util/math/Box;)Z"
|
||||||
@@ -142,7 +148,7 @@ public class SpawnHelperMixin
|
|||||||
return entityType.create(world_1);
|
return entityType.create(world_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;)V", at = @At(
|
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$class_5261;Lnet/minecraft/world/SpawnHelper$class_5259;)V", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
|
target = "Lnet/minecraft/server/world/ServerWorld;spawnEntity(Lnet/minecraft/entity/Entity;)Z"
|
||||||
))
|
))
|
||||||
@@ -165,7 +171,7 @@ public class SpawnHelperMixin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;)V", at = @At(
|
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$class_5261;Lnet/minecraft/world/SpawnHelper$class_5259;)V", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;"
|
target = "Lnet/minecraft/entity/mob/MobEntity;initialize(Lnet/minecraft/world/IWorld;Lnet/minecraft/world/LocalDifficulty;Lnet/minecraft/entity/SpawnType;Lnet/minecraft/entity/EntityData;Lnet/minecraft/nbt/CompoundTag;)Lnet/minecraft/entity/EntityData;"
|
||||||
))
|
))
|
||||||
@@ -176,7 +182,7 @@ public class SpawnHelperMixin
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;)V", at = @At(
|
@Redirect(method = "spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/Chunk;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/world/SpawnHelper$class_5261;Lnet/minecraft/world/SpawnHelper$class_5259;)V", at = @At(
|
||||||
value = "INVOKE",
|
value = "INVOKE",
|
||||||
target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D"
|
target = "Lnet/minecraft/entity/player/PlayerEntity;squaredDistanceTo(DDD)D"
|
||||||
))
|
))
|
||||||
@@ -188,4 +194,69 @@ public class SpawnHelperMixin
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
return distanceTo;
|
return distanceTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
////
|
||||||
|
|
||||||
|
@Redirect(method = "method_27821", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/world/SpawnHelper;spawnEntitiesInChunk(Lnet/minecraft/entity/EntityCategory;Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/SpawnHelper$class_5261;Lnet/minecraft/world/SpawnHelper$class_5259;)V"
|
||||||
|
))
|
||||||
|
// inject our repeat of spawns if more spawn ticks per tick are chosen.
|
||||||
|
private static void spawnMultipleTimes(EntityCategory category, ServerWorld world, WorldChunk chunk, SpawnHelper.class_5261 arg, SpawnHelper.class_5259 arg2)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < SpawnReporter.spawn_tries.get(category); i++)
|
||||||
|
{
|
||||||
|
SpawnHelper.spawnEntitiesInChunk(category, world, chunk, arg, arg2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Redirect(method = "method_27821", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "Lnet/minecraft/world/SpawnHelper$class_5262;method_27826(Lnet/minecraft/entity/EntityCategory;)Z"
|
||||||
|
))
|
||||||
|
// allows to change mobcaps and captures each category try per dimension before it fails due to full mobcaps.
|
||||||
|
private static boolean getNewMobcaps(
|
||||||
|
SpawnHelper.class_5262 class_526, EntityCategory entityCategory,
|
||||||
|
ServerWorld serverWorld, WorldChunk worldChunk, Object arg, boolean bl, boolean bl2, boolean bl3)
|
||||||
|
{
|
||||||
|
DimensionType dim = serverWorld.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 / field_24392; //current spawning limits
|
||||||
|
int mobCount = class_526.method_27830().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 || class_526.method_27830().getInt(entityCategory) < newCap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import net.minecraft.block.BlockEntityProvider;
|
|||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.entity.BlockEntity;
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.class_5217;
|
import net.minecraft.class_5217;
|
||||||
|
import net.minecraft.class_5269;
|
||||||
import net.minecraft.server.world.ChunkHolder;
|
import net.minecraft.server.world.ChunkHolder;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.profiler.Profiler;
|
import net.minecraft.util.profiler.Profiler;
|
||||||
@@ -29,7 +30,7 @@ public abstract class World_movableTEMixin implements WorldInterface
|
|||||||
public boolean isClient;
|
public boolean isClient;
|
||||||
@Shadow
|
@Shadow
|
||||||
@Final
|
@Final
|
||||||
protected class_5217 properties; //LevelProperties
|
protected class_5269 properties; //LevelProperties
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
|
public abstract WorldChunk getWorldChunk(BlockPos blockPos_1);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class HUDController
|
|||||||
dim = DimensionType.THE_END;
|
dim = DimensionType.THE_END;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return new BaseText[]{SpawnReporter.printMobcapsForDimension(dim, false).get(0)};
|
return new BaseText[]{SpawnReporter.printMobcapsForDimension(server.getWorld(dim), false).get(0)};
|
||||||
});
|
});
|
||||||
|
|
||||||
if(LoggerRegistry.__counter)
|
if(LoggerRegistry.__counter)
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ public class SpawnReporter
|
|||||||
public static boolean mock_spawns = false;
|
public static boolean mock_spawns = false;
|
||||||
|
|
||||||
public static Long track_spawns = 0L;
|
public static Long track_spawns = 0L;
|
||||||
public static final HashMap<DimensionType, Object2IntMap<EntityCategory>> mobCounts = new HashMap<>();
|
|
||||||
public static final HashMap<DimensionType, Integer> chunkCounts = new HashMap<>();
|
public static final HashMap<DimensionType, Integer> chunkCounts = new HashMap<>();
|
||||||
|
|
||||||
public static final HashMap<Pair<DimensionType, EntityCategory>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
|
public static final HashMap<Pair<DimensionType, EntityCategory>, Object2LongMap<EntityType>> spawn_stats = new HashMap<>();
|
||||||
@@ -82,13 +81,15 @@ public class SpawnReporter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static List<BaseText> printMobcapsForDimension(DimensionType dim, boolean multiline)
|
public static List<BaseText> printMobcapsForDimension(ServerWorld world, boolean multiline)
|
||||||
{
|
{
|
||||||
|
DimensionType dim = world.getDimension().getType();
|
||||||
String name = dim.toString();
|
String name = dim.toString();
|
||||||
List<BaseText> lst = new ArrayList<>();
|
List<BaseText> lst = new ArrayList<>();
|
||||||
if (multiline)
|
if (multiline)
|
||||||
lst.add(Messenger.s(String.format("Mobcaps for %s:",name)));
|
lst.add(Messenger.s(String.format("Mobcaps for %s:",name)));
|
||||||
Object2IntMap<EntityCategory> dimCounts = mobCounts.get(dim);
|
SpawnHelper.class_5262 lastSpawner = world.getChunkManager().method_27908();
|
||||||
|
Object2IntMap<EntityCategory> dimCounts = lastSpawner.method_27830();
|
||||||
int chunkcount = chunkCounts.getOrDefault(dim, -1);
|
int chunkcount = chunkCounts.getOrDefault(dim, -1);
|
||||||
if (dimCounts == null || chunkcount < 0)
|
if (dimCounts == null || chunkcount < 0)
|
||||||
{
|
{
|
||||||
@@ -163,7 +164,7 @@ public class SpawnReporter
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<BaseText> show_mobcaps(BlockPos pos, World worldIn)
|
public static List<BaseText> show_mobcaps(BlockPos pos, ServerWorld worldIn)
|
||||||
{
|
{
|
||||||
DyeColor under = WoolTool.getWoolColorAtPosition(worldIn, pos.down());
|
DyeColor under = WoolTool.getWoolColorAtPosition(worldIn, pos.down());
|
||||||
if (under == null)
|
if (under == null)
|
||||||
@@ -174,7 +175,7 @@ public class SpawnReporter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return printMobcapsForDimension(worldIn.dimension.getType(), true );
|
return printMobcapsForDimension(worldIn, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EntityCategory creature_type = get_type_code_from_wool_code(under);
|
EntityCategory creature_type = get_type_code_from_wool_code(under);
|
||||||
@@ -197,7 +198,7 @@ public class SpawnReporter
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return printMobcapsForDimension(worldIn.dimension.getType(), true );
|
return printMobcapsForDimension(worldIn, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user