1 parent
efddb904a0
commit
fbe37017c5
7 files changed
+203
-235
No files matched your search
@@ -161,7 +161,7 @@ public class NaturalSpawnerMixin
|
||||
// we used the mob - next time we will create a new one when needed
|
||||
((LevelInterface) world).getPrecookedMobs().remove(entity_1.getType());
|
||||
|
||||
if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null)
|
||||
if (SpawnReporter.trackingSpawns() && SpawnReporter.local_spawns != null)
|
||||
{
|
||||
SpawnReporter.registerSpawn(
|
||||
//world.method_27983(), // getDimensionType //dimension.getType(), // getDimensionType
|
||||
@@ -169,7 +169,7 @@ public class NaturalSpawnerMixin
|
||||
group, //entity_1.getType().getSpawnGroup(),
|
||||
entity_1.blockPosition());
|
||||
}
|
||||
if (!SpawnReporter.mock_spawns)
|
||||
if (!SpawnReporter.mockSpawns)
|
||||
world.addFreshEntityWithPassengers(entity_1);
|
||||
//world.spawnEntity(entity_1);
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class NaturalSpawnerMixin
|
||||
))
|
||||
private static SpawnGroupData spawnEntity(Mob mobEntity, ServerLevelAccessor serverWorldAccess, DifficultyInstance difficulty, MobSpawnType spawnReason, SpawnGroupData entityData, CompoundTag entityTag)
|
||||
{
|
||||
if (!SpawnReporter.mock_spawns) // WorldAccess
|
||||
if (!SpawnReporter.mockSpawns) // WorldAccess
|
||||
return mobEntity.finalizeSpawn(serverWorldAccess, difficulty, spawnReason, entityData, entityTag);
|
||||
return null;
|
||||
}
|
||||
@@ -273,7 +273,7 @@ public class NaturalSpawnerMixin
|
||||
private static void checkSpawns(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState info,
|
||||
boolean spawnAnimals, boolean spawnMonsters, boolean shouldSpawnAnimals, CallbackInfo ci)
|
||||
{
|
||||
if (SpawnReporter.track_spawns > 0L)
|
||||
if (SpawnReporter.trackingSpawns())
|
||||
{
|
||||
MobCategory[] var6 = SPAWNING_CATEGORIES;
|
||||
int var7 = var6.length;
|
||||
@@ -288,23 +288,20 @@ public class NaturalSpawnerMixin
|
||||
int int_3 = newCap * int_2 / MAGIC_NUMBER; //current spawning limits
|
||||
int mobCount = info.getMobCategoryCounts().getInt(entityCategory);
|
||||
|
||||
if (SpawnReporter.track_spawns > 0L && !SpawnReporter.first_chunk_marker.contains(entityCategory))
|
||||
if (SpawnReporter.trackingSpawns() && !SpawnReporter.first_chunk_marker.contains(entityCategory))
|
||||
{
|
||||
SpawnReporter.first_chunk_marker.add(entityCategory);
|
||||
//first chunk with spawn eligibility for that category
|
||||
Pair<ResourceKey<Level>, MobCategory> 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_attempts.addTo(key, spawnTries);
|
||||
|
||||
SpawnReporter.spawn_cap_count.put(key,
|
||||
SpawnReporter.spawn_cap_count.get(key) + mobCount);
|
||||
SpawnReporter.spawn_cap_count.addTo(key, mobCount);
|
||||
}
|
||||
|
||||
if (mobCount <= int_3 || SpawnReporter.mock_spawns) //TODO this will not float with player based mobcaps
|
||||
if (mobCount <= int_3 || SpawnReporter.mockSpawns) //TODO this will not float with player based mobcaps
|
||||
{
|
||||
//place 0 to indicate there were spawn attempts for a category
|
||||
//if (entityCategory != EntityCategory.CREATURE || world.getServer().getTicks() % 400 == 0)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.utils.SpawnReporter;
|
||||
import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -10,7 +11,6 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.DistanceManager;
|
||||
@@ -39,17 +39,15 @@ public abstract class ServerChunkCacheMixin
|
||||
//((WorldInterface)world).getPrecookedMobs().clear(); not needed because mobs are compared with predefined BBs
|
||||
SpawnReporter.chunkCounts.put(dim, j);
|
||||
|
||||
if (SpawnReporter.track_spawns > 0L)
|
||||
if (SpawnReporter.trackingSpawns())
|
||||
{
|
||||
//local spawns now need to be tracked globally cause each calll is just for chunk
|
||||
SpawnReporter.local_spawns = new HashMap<>();
|
||||
SpawnReporter.local_spawns = new Object2LongOpenHashMap<>();
|
||||
SpawnReporter.first_chunk_marker = new HashSet<>();
|
||||
for (MobCategory cat : MobCategory.values())
|
||||
for (MobCategory cat : SpawnReporter.cachedMobCategories())
|
||||
{
|
||||
Pair<ResourceKey<Level>, MobCategory> key = Pair.of(dim, cat);
|
||||
SpawnReporter.overall_spawn_ticks.put(key,
|
||||
SpawnReporter.overall_spawn_ticks.get(key)+
|
||||
SpawnReporter.spawn_tries.get(cat));
|
||||
SpawnReporter.overall_spawn_ticks.addTo(key, SpawnReporter.spawn_tries.get(cat));
|
||||
}
|
||||
}
|
||||
return j;
|
||||
@@ -59,11 +57,11 @@ public abstract class ServerChunkCacheMixin
|
||||
@Inject(method = "tickChunks", at = @At("RETURN"))
|
||||
private void onFinishSpawnWorldCycle(CallbackInfo ci)
|
||||
{
|
||||
LevelData levelProperties_1 = this.level.getLevelData(); // levelProperies class
|
||||
boolean boolean_3 = levelProperties_1.getGameTime() % 400L == 0L;
|
||||
if (SpawnReporter.track_spawns > 0L && SpawnReporter.local_spawns != null)
|
||||
LevelData levelData = this.level.getLevelData(); // levelProperies class
|
||||
boolean boolean_3 = levelData.getGameTime() % 400L == 0L;
|
||||
if (SpawnReporter.trackingSpawns() && SpawnReporter.local_spawns != null)
|
||||
{
|
||||
for (MobCategory cat: MobCategory.values())
|
||||
for (MobCategory cat: SpawnReporter.cachedMobCategories())
|
||||
{
|
||||
ResourceKey<Level> dim = level.dimension(); // getDimensionType;
|
||||
Pair<ResourceKey<Level>, MobCategory> key = Pair.of(dim, cat);
|
||||
@@ -73,19 +71,15 @@ public abstract class ServerChunkCacheMixin
|
||||
if (!cat.isPersistent() || boolean_3) // isAnimal
|
||||
{
|
||||
// fill mobcaps for that category so spawn got cancelled
|
||||
SpawnReporter.spawn_ticks_full.put(key,
|
||||
SpawnReporter.spawn_ticks_full.get(key)+ spawnTries);
|
||||
SpawnReporter.spawn_ticks_full.addTo(key, spawnTries);
|
||||
}
|
||||
|
||||
}
|
||||
else if (SpawnReporter.local_spawns.get(cat) > 0)
|
||||
else if (SpawnReporter.local_spawns.getLong(cat) > 0)
|
||||
{
|
||||
// tick spawned mobs for that type
|
||||
SpawnReporter.spawn_ticks_succ.put(key,
|
||||
SpawnReporter.spawn_ticks_succ.get(key)+spawnTries);
|
||||
SpawnReporter.spawn_ticks_spawns.put(key,
|
||||
SpawnReporter.spawn_ticks_spawns.get(key)+
|
||||
SpawnReporter.local_spawns.get(cat));
|
||||
SpawnReporter.spawn_ticks_succ.addTo(key, spawnTries);
|
||||
SpawnReporter.spawn_ticks_spawns.addTo(key, SpawnReporter.local_spawns.getLong(cat));
|
||||
// this will be off comparing to 1.13 as that would succeed if
|
||||
// ANY tries in that round were successful.
|
||||
// there will be much more difficult to mix in
|
||||
@@ -95,8 +89,7 @@ public abstract class ServerChunkCacheMixin
|
||||
else // spawn no mobs despite trying
|
||||
{
|
||||
//tick didn's spawn mobs of that type
|
||||
SpawnReporter.spawn_ticks_fail.put(key,
|
||||
SpawnReporter.spawn_ticks_fail.get(key)+spawnTries);
|
||||
SpawnReporter.spawn_ticks_fail.addTo(key, spawnTries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import net.minecraft.world.level.storage.WritableLevelData;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@@ -37,7 +38,6 @@ import static carpet.script.CarpetEventServer.Event.EXPLOSION;
|
||||
import static carpet.script.CarpetEventServer.Event.LIGHTNING;
|
||||
import static carpet.script.CarpetEventServer.Event.CHUNK_UNLOADED;
|
||||
|
||||
|
||||
@Mixin(ServerLevel.class)
|
||||
public abstract class ServerLevel_scarpetMixin extends Level implements ServerWorldInterface
|
||||
{
|
||||
@@ -94,11 +94,13 @@ public abstract class ServerLevel_scarpetMixin extends Level implements ServerWo
|
||||
private ServerLevelData serverLevelData;
|
||||
@Shadow @Final private PersistentEntitySectionManager<Entity> entityManager;
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public ServerLevelData getWorldPropertiesCM(){
|
||||
return serverLevelData;
|
||||
}
|
||||
|
||||
@Unique
|
||||
@Override
|
||||
public LevelEntityGetter<Entity> getEntityLookupCMPublic() {
|
||||
return entityManager.getEntityGetter();
|
||||
|
||||
Reference in new issue
Block a user