there can be more than 3 dimensions, fixes #336
This commit is contained in:
1 parent
3700377686
commit
5cb019d5b5
3 files changed
+38
-11
No files matched your search
@@ -127,6 +127,7 @@ import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.gen.feature.Feature;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import net.minecraft.world.SpawnHelper;
|
||||
@@ -3219,7 +3220,20 @@ public class CarpetExpression
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(World.OVERWORLD)); //ow
|
||||
break;
|
||||
default:
|
||||
RegistryKey<World> dim = null;
|
||||
Identifier id = new Identifier(dimString);
|
||||
// not using RegistryKey.of since that one creates on check
|
||||
for (RegistryKey<World> world : (outerSource.getMinecraftServer().getWorldRegistryKeys()))
|
||||
{
|
||||
if (id.equals(world.getValue()))
|
||||
{
|
||||
dim = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dim == null)
|
||||
throw new InternalExpressionException("Incorrect dimension string: "+dimString);
|
||||
innerSource = outerSource.withWorld(outerSource.getMinecraftServer().getWorld(dim));
|
||||
}
|
||||
}
|
||||
((CarpetContext) c).s = innerSource;
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.Comparator;
|
||||
@@ -22,7 +23,6 @@ public class CarpetProfiler
|
||||
private static TYPE test_type = TYPE.NONE; //1 for ticks, 2 for entities;
|
||||
private static long current_tick_start = 0;
|
||||
private static final String[] GENERAL_SECTIONS = {"Network", "Autosave", "Async Tasks"};
|
||||
private static final String[] DIMENSIONS = {"overworld", "the_end", "the_nether"};
|
||||
private static final String[] SECTIONS = {
|
||||
"Spawning and Random Ticks", "Ticket Manager","Unloading",
|
||||
"Blocks", "Entities", "Block Entities",
|
||||
@@ -56,7 +56,7 @@ public class CarpetProfiler
|
||||
private static String getSectionString(World world, String section)
|
||||
{
|
||||
return String.format("%s.%s%s",
|
||||
world.getRegistryKey().getValue().toString().replaceFirst("minecraft:", ""),
|
||||
world.getRegistryKey().getValue().getPath(),
|
||||
section, // ^ getDImension getId
|
||||
world.isClient ? " (Client)" : "");
|
||||
}
|
||||
@@ -64,19 +64,24 @@ public class CarpetProfiler
|
||||
private static String getEntityString(World world, Entity e)
|
||||
{
|
||||
return String.format("%s.%s%s",
|
||||
world.getRegistryKey().getValue().toString().replaceFirst("minecraft:", ""),
|
||||
Registry.ENTITY_TYPE.getId(e.getType()).toString().replaceFirst("minecraft:", ""),
|
||||
world.getRegistryKey().getValue().getPath(),
|
||||
Registry.ENTITY_TYPE.getId(e.getType()).getPath(),
|
||||
world.isClient ? " (Client)" : "");
|
||||
}
|
||||
|
||||
private static String getTEntityString(World world, BlockEntity be)
|
||||
{
|
||||
return String.format("%s.%s%s",
|
||||
world.getRegistryKey().getValue().toString().replaceFirst("minecraft:", ""),
|
||||
Registry.BLOCK_ENTITY_TYPE.getId(be.getType()).toString().replaceFirst("minecraft:", ""),
|
||||
world.getRegistryKey().getValue().getPath(),
|
||||
Registry.BLOCK_ENTITY_TYPE.getId(be.getType()).getPath(),
|
||||
world.isClient ? " (Client)" : "");
|
||||
}
|
||||
|
||||
private static String getDimName(RegistryKey<World> world)
|
||||
{
|
||||
return world.getValue().getPath();
|
||||
}
|
||||
|
||||
public static void prepare_tick_report(ServerCommandSource source, int ticks)
|
||||
{
|
||||
//maybe add so it only spams the sending player, but honestly - all may want to see it
|
||||
@@ -89,11 +94,11 @@ public class CarpetProfiler
|
||||
{
|
||||
time_repo.put(section, 0L);
|
||||
}
|
||||
for (String level : DIMENSIONS)
|
||||
for (RegistryKey<World> level : source.getMinecraftServer().getWorldRegistryKeys())
|
||||
{
|
||||
for (String section : SECTIONS)
|
||||
{
|
||||
time_repo.put(level + "." + section, 0L);
|
||||
time_repo.put(getDimName(level) + "." + section, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,8 +230,9 @@ public class CarpetProfiler
|
||||
}
|
||||
}
|
||||
|
||||
for (String dimension : DIMENSIONS)
|
||||
for (RegistryKey<World> dim : server.getWorldRegistryKeys())
|
||||
{
|
||||
String dimension = getDimName(dim);
|
||||
boolean hasSomethin = false;
|
||||
for (String section : SECTIONS)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SpawnReporter
|
||||
{
|
||||
@@ -326,6 +327,12 @@ public class SpawnReporter
|
||||
track_spawns = 0L;
|
||||
}
|
||||
|
||||
private static String getWorldCode(RegistryKey<World> world)
|
||||
{
|
||||
if (world == World.OVERWORLD) return "";
|
||||
return "("+world.getValue().getPath().toUpperCase(Locale.ROOT).replace("THE_","").charAt(0)+")";
|
||||
}
|
||||
|
||||
public static List<BaseText> tracking_report(World worldIn)
|
||||
{
|
||||
|
||||
@@ -349,7 +356,7 @@ public class SpawnReporter
|
||||
{
|
||||
//String type_code = String.format("%s", enumcreaturetype);
|
||||
boolean there_are_mobs_to_list = false;
|
||||
for (RegistryKey<World> dim : Arrays.asList(World.OVERWORLD, World.NETHER, World.END)) //String world_code: new String[] {"", " (N)", " (E)"})
|
||||
for (RegistryKey<World> dim : worldIn.getServer().getWorldRegistryKeys()) //String world_code: new String[] {"", " (N)", " (E)"})
|
||||
{
|
||||
Pair<RegistryKey<World>, SpawnGroup> code = Pair.of(dim, enumcreaturetype);
|
||||
if (spawn_ticks_spawns.get(code) > 0L)
|
||||
@@ -357,7 +364,7 @@ public class SpawnReporter
|
||||
there_are_mobs_to_list = true;
|
||||
double hours = overall_spawn_ticks.get(code)/72000.0;
|
||||
report.add(Messenger.s(String.format(" > %s (%.1f min), %.1f m/t, {%.1f%%F / %.1f%%- / %.1f%%+}; %.2f s/att",
|
||||
code.getRight()+((code.getLeft()==World.OVERWORLD)?"":( (code.getLeft()==World.NETHER)?"(N)":"(E)" )), // OW, nether
|
||||
getWorldCode(dim),
|
||||
60*hours,
|
||||
(1.0D*spawn_cap_count.get(code))/ spawn_attempts.get(code),
|
||||
(100.0D*spawn_ticks_full.get(code))/ spawn_attempts.get(code),
|
||||
|
||||
Reference in new issue
Block a user