primitive chunk table in world snapshot instead of colliding long-keyed hashmap, bounded cache for tinted/composited mob and banner textures, vanilla dump with nested model json, village benchmark and perf test scenes
This commit is contained in:
1 parent
b5baffebbd
commit
88bae41a03
10 files changed
+306
-38
No files matched your search
@@ -141,6 +141,10 @@ public class PPTest extends JavaPlugin {
|
||||
scenes.put("perf_farm", new Scene("perf_farm", this::perfFarm, -6, 9, -13, 4, 0, 0));
|
||||
scenes.put("perf_farm_close", new Scene("perf_farm_close", this::perfFarm, 0.5, 3, -11.5, 5, 0.5, -4));
|
||||
scenes.put("perf_items", new Scene("perf_items", this::perfItems, 0.5, 5, -10, 5, 0, -2));
|
||||
// Per-mob texture compositing (tinted-texture cache): villager type/profession/level, sheep colours, dyed
|
||||
// leather armor, wolf collars and patterned banners, all from a seeded RNG (deterministic).
|
||||
scenes.put("perf_village", new Scene("perf_village", this::perfVillage, -6, 9, -13, 4, 0, 0));
|
||||
scenes.put("perf_village_close", new Scene("perf_village_close", this::perfVillage, 0.5, 3, -11.5, 5, 0.5, -4));
|
||||
}
|
||||
|
||||
private void perfFarm(Location o) {
|
||||
@@ -156,6 +160,71 @@ public class PPTest extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void perfVillage(Location o) {
|
||||
Random r = new Random(11);
|
||||
List<Villager.Type> vTypes = registry(io.papermc.paper.registry.RegistryKey.VILLAGER_TYPE);
|
||||
List<Villager.Profession> profs = registry(io.papermc.paper.registry.RegistryKey.VILLAGER_PROFESSION);
|
||||
DyeColor[] dyes = DyeColor.values();
|
||||
for (int i = 0; i < 14; i++)
|
||||
for (int j = 0; j < 16; j++) {
|
||||
double x = -5 + i * 1.2, z = -10 + j * 1.2;
|
||||
DyeColor dye = dyes[r.nextInt(dyes.length)];
|
||||
LivingEntity e;
|
||||
switch (r.nextInt(4)) {
|
||||
case 0 -> {
|
||||
Villager v = rfSpawn(o, x, 0, z, 0, Villager.class);
|
||||
v.setVillagerType(vTypes.get(r.nextInt(vTypes.size())));
|
||||
if (r.nextInt(6) == 0) v.setBaby();
|
||||
else {
|
||||
v.setProfession(profs.get(r.nextInt(profs.size())));
|
||||
v.setVillagerLevel(1 + r.nextInt(5));
|
||||
}
|
||||
e = v;
|
||||
}
|
||||
case 1 -> {
|
||||
Sheep sh = rfSpawn(o, x, 0, z, 0, Sheep.class);
|
||||
sh.setColor(dye);
|
||||
if (r.nextInt(6) == 0) sh.setBaby();
|
||||
e = sh;
|
||||
}
|
||||
case 2 -> {
|
||||
Zombie zo = rfSpawn(o, x, 0, z, 0, Zombie.class);
|
||||
Material[] pieces = {Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE,
|
||||
Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS};
|
||||
ItemStack[] armor = new ItemStack[4];
|
||||
for (int k = 0; k < 4; k++) {
|
||||
armor[k] = it(pieces[k]);
|
||||
org.bukkit.inventory.meta.LeatherArmorMeta m =
|
||||
(org.bukkit.inventory.meta.LeatherArmorMeta) armor[k].getItemMeta();
|
||||
m.setColor(dye.getColor());
|
||||
armor[k].setItemMeta(m);
|
||||
}
|
||||
zo.getEquipment().setHelmet(armor[0]);
|
||||
zo.getEquipment().setChestplate(armor[1]);
|
||||
zo.getEquipment().setLeggings(armor[2]);
|
||||
zo.getEquipment().setBoots(armor[3]);
|
||||
e = zo;
|
||||
}
|
||||
default -> {
|
||||
Wolf wo = rfSpawn(o, x, 0, z, 0, Wolf.class);
|
||||
tame(wo, dye);
|
||||
if (r.nextInt(6) == 0) wo.setBaby();
|
||||
e = wo;
|
||||
}
|
||||
}
|
||||
e.setBodyYaw(r.nextInt(8) * 45);
|
||||
}
|
||||
for (int b = 0; b < 10; b++) {
|
||||
int x = -4 + b * 2;
|
||||
put(o, x, 0, 10, dyes[r.nextInt(dyes.length)].name().toLowerCase() + "_banner[rotation=" + r.nextInt(16) + "]");
|
||||
if (o.clone().add(x, 0, 10).getBlock().getState() instanceof org.bukkit.block.Banner bn) {
|
||||
bn.addPattern(new org.bukkit.block.banner.Pattern(dyes[r.nextInt(dyes.length)], org.bukkit.block.banner.PatternType.STRIPE_TOP));
|
||||
bn.addPattern(new org.bukkit.block.banner.Pattern(dyes[r.nextInt(dyes.length)], org.bukkit.block.banner.PatternType.CREEPER));
|
||||
bn.update(true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void perfItems(Location o) {
|
||||
Random r = new Random(7);
|
||||
Material[] mats = {Material.WHEAT, Material.CARROT, Material.EGG, Material.BONE, Material.ROTTEN_FLESH,
|
||||
|
||||
Reference in new issue
Block a user