Merge branch 'parity-base' into parity/leftovers
This commit is contained in:
@@ -593,7 +593,15 @@ public final class VanillaHudOracle {
|
||||
default -> chat.addPlayerMessage(text, null, null);
|
||||
}
|
||||
}
|
||||
chat.extractRenderState(capture, font, i("now", 0), 0, 0, net.minecraft.client.gui.components.ChatComponent.DisplayMode.BACKGROUND, false);
|
||||
// Focused: the chat screen is open (isChatFocused), the chat is drawn in the
|
||||
// foreground and may be scrolled.
|
||||
boolean focused = c.has("focused") && b("focused");
|
||||
if (focused) put(gui, net.minecraft.client.gui.Gui.class, "screen", alloc(net.minecraft.client.gui.screens.ChatScreen.class));
|
||||
if (c.has("scroll")) chat.scrollChat(i("scroll", 0));
|
||||
chat.extractRenderState(capture, font, i("now", 0), 0, 0, focused
|
||||
? net.minecraft.client.gui.components.ChatComponent.DisplayMode.FOREGROUND
|
||||
: net.minecraft.client.gui.components.ChatComponent.DisplayMode.BACKGROUND, false);
|
||||
put(gui, net.minecraft.client.gui.Gui.class, "screen", null);
|
||||
}
|
||||
default -> throw new IllegalArgumentException(c.get("kind").getAsString());
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ public final class VanillaMobAiOracle {
|
||||
}
|
||||
}
|
||||
case "origin" -> { s.originX = Integer.parseInt(f[1]); s.originZ = Integer.parseInt(f[2]); }
|
||||
case "fill", "block" -> s.blocks.add(f);
|
||||
case "fill", "block", "chest" -> s.blocks.add(f);
|
||||
case "at" -> s.timed.add(new Object[] {Integer.parseInt(f[1]), java.util.Arrays.copyOfRange(f, 2, f.length)});
|
||||
case "watch" -> {
|
||||
int[] box = new int[6];
|
||||
@@ -450,9 +450,21 @@ public final class VanillaMobAiOracle {
|
||||
static void place(String[] b, ServerLevel level) throws Exception {
|
||||
var blocks = level.holderLookup(Registries.BLOCK);
|
||||
{
|
||||
if (b[0].equals("block")) {
|
||||
if (b[0].equals("block") || b[0].equals("chest")) {
|
||||
BlockState state = BlockStateParser.parseForBlock(blocks, b[4], false).blockState();
|
||||
level.setBlock(new BlockPos(Integer.parseInt(b[1]), Integer.parseInt(b[2]), Integer.parseInt(b[3])), state, 2 | 16);
|
||||
BlockPos at = new BlockPos(Integer.parseInt(b[1]), Integer.parseInt(b[2]), Integer.parseInt(b[3]));
|
||||
level.setBlock(at, state, 2 | 16);
|
||||
// chest X Y Z STATE SLOTS: the slots' contents (item*count, - for empty).
|
||||
if (b[0].equals("chest") && b.length > 5) {
|
||||
var chest = (net.minecraft.world.level.block.entity.ChestBlockEntity) level.getBlockEntity(at);
|
||||
String[] slots = b[5].split(",");
|
||||
for (int k = 0; k < slots.length; k++) {
|
||||
if (slots[k].equals("-")) continue;
|
||||
String[] ic = slots[k].split("\\*");
|
||||
chest.setItem(k, new net.minecraft.world.item.ItemStack(
|
||||
BuiltInRegistries.ITEM.getValue(net.minecraft.resources.Identifier.parse(ic[0])), Integer.parseInt(ic[1])));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BlockState state = BlockStateParser.parseForBlock(blocks, b[7], false).blockState();
|
||||
int x0 = Integer.parseInt(b[1]), y0 = Integer.parseInt(b[2]), z0 = Integer.parseInt(b[3]);
|
||||
@@ -575,6 +587,14 @@ public final class VanillaMobAiOracle {
|
||||
case "leashed", "leashto" -> {
|
||||
// Leashed once every mob exists (below).
|
||||
}
|
||||
case "hand" -> {
|
||||
String[] ic = v.split("\\*");
|
||||
mob.setItemSlot(net.minecraft.world.entity.EquipmentSlot.MAINHAND, new net.minecraft.world.item.ItemStack(
|
||||
BuiltInRegistries.ITEM.getValue(net.minecraft.resources.Identifier.parse(ic[0])), Integer.parseInt(ic[1])));
|
||||
}
|
||||
case "cooldown" -> {
|
||||
// Set after the seeded constructor draw (below).
|
||||
}
|
||||
default -> throw new IllegalArgumentException(flag);
|
||||
}
|
||||
}
|
||||
@@ -582,6 +602,15 @@ public final class VanillaMobAiOracle {
|
||||
for (Runnable r : afterAdd) r.run();
|
||||
mob.getRandom().setSeed(spec.seed);
|
||||
Brain<?> brain = mob.getBrain();
|
||||
if (mob instanceof net.minecraft.world.entity.animal.golem.CopperGolem) {
|
||||
// The constructor's TRANSPORT_ITEMS_COOLDOWN_TICKS draw, made with the seeded
|
||||
// random; "cooldown=N" then sets it (0: none, transporting at once).
|
||||
int cooldown = mob.getRandom().nextInt(60, 100);
|
||||
for (String flag : spec.flags)
|
||||
if (flag.startsWith("cooldown=")) cooldown = Integer.parseInt(flag.substring(9));
|
||||
if (cooldown > 0) brain.setMemory(MemoryModuleType.TRANSPORT_ITEMS_COOLDOWN_TICKS, cooldown);
|
||||
else brain.eraseMemory(MemoryModuleType.TRANSPORT_ITEMS_COOLDOWN_TICKS);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<Object, Sensor<?>> sensors = (Map<Object, Sensor<?>>) get(brain, "sensors");
|
||||
for (Sensor<?> sensor : sensors.values()) sensor.randomlyDelayStart(mob.getRandom());
|
||||
@@ -732,6 +761,7 @@ public final class VanillaMobAiOracle {
|
||||
}
|
||||
for (int i = 0; i < ENTS.size(); i++) print(t, i, ENTS.get(i));
|
||||
for (BlockPos h : heartPositions) printHeart(t, level, h);
|
||||
for (String[] b : s.blocks) if (b[0].equals("chest")) printChest(t, s, level, b);
|
||||
for (String sound : SOUNDS) out.println(t + " sound " + sound);
|
||||
for (var w : watched.entrySet()) {
|
||||
BlockState now = level.getBlockState(w.getKey());
|
||||
@@ -765,6 +795,19 @@ public final class VanillaMobAiOracle {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** A chest's slots (trailing empties dropped) and opener count. */
|
||||
static void printChest(int t, Scenario s, ServerLevel level, String[] b) throws Exception {
|
||||
BlockPos at = new BlockPos(Integer.parseInt(b[1]), Integer.parseInt(b[2]), Integer.parseInt(b[3]));
|
||||
if (!(level.getBlockEntity(at) instanceof net.minecraft.world.level.block.entity.ChestBlockEntity chest)) return;
|
||||
List<String> slots = new ArrayList<>();
|
||||
for (int k = 0; k < chest.getContainerSize(); k++) slots.add(stack(chest.getItem(k)));
|
||||
while (!slots.isEmpty() && slots.getLast().equals("-")) slots.removeLast();
|
||||
Object counter = get(chest, "openersCounter");
|
||||
out.println(t + " chest " + (at.getX() - s.originX) + "," + at.getY() + "," + (at.getZ() - s.originZ) + " "
|
||||
+ (slots.isEmpty() ? "-" : String.join(",", slots)) + " "
|
||||
+ ((net.minecraft.world.level.block.entity.ContainerOpenersCounter) counter).getOpenerCount());
|
||||
}
|
||||
|
||||
/** A heart's block state and block entity, and the level random. */
|
||||
static void printHeart(int t, ServerLevel level, BlockPos at) throws Exception {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -923,6 +966,11 @@ public final class VanillaMobAiOracle {
|
||||
sb.append("\tmem ").append(String.join(" ", mem));
|
||||
}
|
||||
if (m instanceof Villager villager) sb.append("\tvx ").append(villager(villager));
|
||||
if (m instanceof net.minecraft.world.entity.animal.golem.CopperGolem golem) {
|
||||
Object opened = get(golem, "openedChestPos");
|
||||
sb.append("\tcg ").append(golem.getState().ordinal()).append(' ').append(stack(golem.getMainHandItem())).append(' ')
|
||||
.append(opened == null ? "-" : pos((BlockPos) opened));
|
||||
}
|
||||
out.println(sb);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package dev.horizonlab.parity;
|
||||
|
||||
import com.google.gson.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import net.minecraft.client.gui.screens.packs.PackSelectionModel;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.packs.PackLocationInfo;
|
||||
import net.minecraft.server.packs.PackSelectionConfig;
|
||||
import net.minecraft.server.packs.repository.Pack;
|
||||
import net.minecraft.server.packs.repository.PackCompatibility;
|
||||
import net.minecraft.server.packs.repository.PackRepository;
|
||||
import net.minecraft.server.packs.repository.PackSource;
|
||||
import net.minecraft.world.flag.FeatureFlagSet;
|
||||
|
||||
/**
|
||||
* Runs the resource pack screen's selection logic: a PackRepository of the
|
||||
* case's packs (required, default position, fixed position, compatibility)
|
||||
* with an initial selection, a PackSelectionModel over it, and the actions
|
||||
* TransferableSelectionList.PackEntry performs on a click or key press:
|
||||
* select (an incompatible pack only once its ConfirmScreen is accepted),
|
||||
* unselect, move up, move down. After each action: both lists and every
|
||||
* entry's canSelect, canUnselect, canMoveUp and canMoveDown; at the end the
|
||||
* repository's selection after commit.
|
||||
*
|
||||
* Input lines: case JSON. Output lines: {steps:[...], committed:[...]} or {error}.
|
||||
*/
|
||||
public final class VanillaPackSelectionOracle {
|
||||
static JsonObject lists(PackSelectionModel model) {
|
||||
var o = new JsonObject();
|
||||
for (String side : new String[] {"unselected", "selected"}) {
|
||||
var a = new JsonArray();
|
||||
var entries = side.equals("selected") ? model.getSelected().toList() : model.getUnselected().toList();
|
||||
for (var e : entries) {
|
||||
var row = new JsonArray();
|
||||
row.add(e.getId());
|
||||
row.add((e.canSelect() ? "s" : "") + (e.canUnselect() ? "u" : "") + (e.canMoveUp() ? "^" : "") + (e.canMoveDown() ? "v" : ""));
|
||||
a.add(row);
|
||||
}
|
||||
o.add(side, a);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ParityData.init();
|
||||
var gson = new Gson();
|
||||
var out = new StringBuilder();
|
||||
for (String line : Files.readAllLines(Path.of(args[0]))) {
|
||||
if (line.isBlank()) continue;
|
||||
JsonObject c = JsonParser.parseString(line).getAsJsonObject();
|
||||
var result = new JsonObject();
|
||||
try {
|
||||
List<Pack> packs = new ArrayList<>();
|
||||
for (var p : c.getAsJsonArray("packs")) {
|
||||
var o = p.getAsJsonObject();
|
||||
String id = o.get("id").getAsString();
|
||||
var location = new PackLocationInfo(id, Component.literal(id), PackSource.DEFAULT, Optional.empty());
|
||||
var compatibility = switch (o.get("compat").getAsString()) {
|
||||
case "old" -> PackCompatibility.TOO_OLD;
|
||||
case "new" -> PackCompatibility.TOO_NEW;
|
||||
default -> PackCompatibility.COMPATIBLE;
|
||||
};
|
||||
var metadata = new Pack.Metadata(Component.literal(id), compatibility, FeatureFlagSet.of(), List.of());
|
||||
var config = new PackSelectionConfig(o.get("required").getAsBoolean(),
|
||||
o.get("position").getAsString().equals("top") ? Pack.Position.TOP : Pack.Position.BOTTOM, o.get("fixed").getAsBoolean());
|
||||
packs.add(new Pack(location, null, metadata, config));
|
||||
}
|
||||
var repository = new PackRepository(consumer -> packs.forEach(consumer));
|
||||
repository.reload();
|
||||
List<String> initial = new ArrayList<>();
|
||||
for (var s : c.getAsJsonArray("selected")) initial.add(s.getAsString());
|
||||
repository.setSelected(initial);
|
||||
var model = new PackSelectionModel(e -> { }, p -> null, repository, r -> { });
|
||||
var steps = new JsonArray();
|
||||
steps.add(lists(model));
|
||||
for (var step : c.getAsJsonArray("ops")) {
|
||||
var o = step.getAsJsonObject();
|
||||
var entries = o.get("list").getAsString().equals("selected") ? model.getSelected().toList() : model.getUnselected().toList();
|
||||
if (!entries.isEmpty()) {
|
||||
var e = entries.get(Math.floorMod(o.get("index").getAsInt(), entries.size()));
|
||||
switch (o.get("op").getAsString()) {
|
||||
// PackEntry.keyPressed(select) / a click on the icon: handlePackSelection or unselect.
|
||||
case "activate" -> {
|
||||
if (e.canSelect()) {
|
||||
if (e.getCompatibility().isCompatible() || o.get("confirm").getAsBoolean()) e.select();
|
||||
} else if (e.canUnselect()) {
|
||||
e.unselect();
|
||||
}
|
||||
}
|
||||
case "up" -> { if (e.canMoveUp()) e.moveUp(); }
|
||||
case "down" -> { if (e.canMoveDown()) e.moveDown(); }
|
||||
default -> throw new IllegalArgumentException(o.toString());
|
||||
}
|
||||
}
|
||||
steps.add(lists(model));
|
||||
}
|
||||
result.add("steps", steps);
|
||||
model.commit();
|
||||
var committed = new JsonArray();
|
||||
for (var p : repository.getSelectedPacks()) committed.add(p.getId());
|
||||
result.add("committed", committed);
|
||||
} catch (Throwable error) {
|
||||
result.addProperty("error", String.valueOf(error));
|
||||
}
|
||||
out.append(gson.toJson(result)).append('\n');
|
||||
}
|
||||
Files.writeString(Path.of(args[1]), out.toString(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
@@ -476,7 +476,12 @@ public final class VanillaProtocolClient {
|
||||
record("play", r.type + " " + json(p.reason()));
|
||||
break;
|
||||
}
|
||||
if (ordered) {
|
||||
// MinecraftServer.tickServer syncs the game time every 20 ticks
|
||||
// (no clocks): whether one lands before the first chunk batch
|
||||
// depends on when the client joined, so it isn't compared.
|
||||
boolean periodicTime = packet instanceof net.minecraft.network.protocol.game.ClientboundSetTimePacket p
|
||||
&& p.clockUpdates().isEmpty();
|
||||
if (ordered && !periodicTime) {
|
||||
record("play-start", r.type + " " + summary(r));
|
||||
}
|
||||
if (packet instanceof net.minecraft.network.protocol.game.ClientboundCommandsPacket p && counts.get(r.type) == 1) {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package dev.horizonlab.parity;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.*;
|
||||
import java.util.Base64;
|
||||
import net.minecraft.client.renderer.texture.SkinTextureDownloader;
|
||||
|
||||
/**
|
||||
* Decodes downloaded skin PNGs as vanilla does (NativeImage.read) and runs
|
||||
* SkinTextureDownloader.processLegacySkin on them: 64x32 skins get the 64x64
|
||||
* layout, opaque parts lose their alpha, other sizes are refused.
|
||||
*
|
||||
* Input lines: base64 PNG. Output lines: base64 RGBA pixels of the result,
|
||||
* or "refused".
|
||||
*/
|
||||
public final class VanillaSkinImageOracle {
|
||||
public static void main(String[] args) throws Exception {
|
||||
Method process = SkinTextureDownloader.class.getDeclaredMethod("processLegacySkin", NativeImage.class, String.class);
|
||||
process.setAccessible(true);
|
||||
var out = new StringBuilder();
|
||||
for (String line : Files.readAllLines(Path.of(args[0]))) {
|
||||
if (line.isBlank()) continue;
|
||||
String result;
|
||||
try {
|
||||
var image = (NativeImage) process.invoke(null, NativeImage.read(Base64.getDecoder().decode(line)), "case");
|
||||
var pixels = new byte[image.getWidth() * image.getHeight() * 4];
|
||||
for (int y = 0, i = 0; y < image.getHeight(); y++) {
|
||||
for (int x = 0; x < image.getWidth(); x++) {
|
||||
int argb = image.getPixel(x, y);
|
||||
pixels[i++] = (byte) (argb >> 16);
|
||||
pixels[i++] = (byte) (argb >> 8);
|
||||
pixels[i++] = (byte) argb;
|
||||
pixels[i++] = (byte) (argb >>> 24);
|
||||
}
|
||||
}
|
||||
image.close();
|
||||
result = Base64.getEncoder().encodeToString(pixels);
|
||||
} catch (java.lang.reflect.InvocationTargetException e) {
|
||||
result = "refused";
|
||||
}
|
||||
out.append(result).append('\n');
|
||||
}
|
||||
Files.writeString(Path.of(args[1]), out.toString(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,22 @@ package dev.horizonlab.parity;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.authlib.services.MinecraftServicesDiscoveryService;
|
||||
import com.mojang.authlib.services.MinecraftServicesSessionService;
|
||||
import com.mojang.authlib.services.ServicesKeyInfo;
|
||||
import com.mojang.authlib.services.ServicesKeySet;
|
||||
import com.mojang.authlib.services.response.discovery.Discovery;
|
||||
import com.mojang.authlib.services.response.discovery.DiscoveryResponse;
|
||||
import com.mojang.authlib.services.response.discovery.Endpoint;
|
||||
import com.mojang.authlib.services.response.discovery.Endpoints;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import net.minecraft.client.renderer.texture.SkinTextureDownloader;
|
||||
import net.minecraft.client.resources.SkinManager;
|
||||
import net.minecraft.core.ClientAsset;
|
||||
import net.minecraft.server.Services;
|
||||
import com.mojang.renderpearl.api.pipeline.RenderPipeline;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import java.lang.reflect.*;
|
||||
@@ -47,6 +63,9 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
* Visibility changes clear the heart states as setVisible does (without
|
||||
* the narration).
|
||||
*
|
||||
* Profiles may carry a signed or unsigned `textures` property; a real
|
||||
* SkinManager (see skinManager) decides each face's texture.
|
||||
*
|
||||
* Input lines: case JSON. Output lines: {case, frames:[[draws]...]} or {case, error}.
|
||||
*/
|
||||
public final class VanillaTabListOracle {
|
||||
@@ -106,6 +125,47 @@ public final class VanillaTabListOracle {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A real SkinManager over a real MinecraftServicesSessionService whose
|
||||
* discovery lists the case's texture URIs and whose profile property key
|
||||
* accepts the signature "valid". Downloads succeed, fail or never finish
|
||||
* by texture hash, as the case says.
|
||||
*/
|
||||
static SkinManager skinManager(JsonObject c) throws Exception {
|
||||
var uris = new ArrayList<String>();
|
||||
for (var u : c.getAsJsonArray("validUris")) uris.add(u.getAsString());
|
||||
var endpoints = new Endpoints(Map.of("getTexture", new Endpoint(null, uris)));
|
||||
var response = new DiscoveryResponse("prod", "minecraft", new Discovery("minecraft", Endpoints.empty(), Endpoints.empty(), Endpoints.empty(), endpoints, Endpoints.empty()));
|
||||
var dc = MinecraftServicesDiscoveryService.class.getDeclaredConstructor(java.net.Proxy.class, boolean.class, java.util.function.Supplier.class);
|
||||
dc.setAccessible(true);
|
||||
var discovery = dc.newInstance(java.net.Proxy.NO_PROXY, false, (java.util.function.Supplier<DiscoveryResponse>) () -> response);
|
||||
var key = (ServicesKeyInfo) Proxy.newProxyInstance(ServicesKeyInfo.class.getClassLoader(), new Class<?>[] {ServicesKeyInfo.class},
|
||||
(proxy, method, a) -> switch (method.getName()) {
|
||||
case "validateProperty" -> "valid".equals(((Property) a[0]).signature());
|
||||
case "keyBitCount" -> 4096;
|
||||
default -> throw new UnsupportedOperationException(method.getName());
|
||||
});
|
||||
ServicesKeySet keys = type -> List.of(key);
|
||||
var sc = MinecraftServicesSessionService.class.getDeclaredConstructor(ServicesKeySet.class, java.net.Proxy.class, MinecraftServicesDiscoveryService.class);
|
||||
sc.setAccessible(true);
|
||||
var session = sc.newInstance(keys, java.net.Proxy.NO_PROXY, discovery);
|
||||
var downloads = c.getAsJsonObject("downloads");
|
||||
var downloader = new SkinTextureDownloader(java.net.Proxy.NO_PROXY, null, Runnable::run) {
|
||||
@Override
|
||||
public CompletableFuture<ClientAsset.Texture> downloadAndRegisterSkin(Identifier textureId, Path localCopy, String url, boolean processLegacySkin) {
|
||||
String hash = new MinecraftProfileTexture(url, Map.of()).getHash();
|
||||
String state = downloads.has(hash) ? downloads.get(hash).getAsString() : "ok";
|
||||
return switch (state) {
|
||||
case "ok" -> CompletableFuture.completedFuture(new ClientAsset.DownloadedTexture(textureId, url));
|
||||
case "pending" -> new CompletableFuture<>();
|
||||
default -> CompletableFuture.failedFuture(new java.io.IOException("download failed"));
|
||||
};
|
||||
}
|
||||
};
|
||||
var services = new Services(session, keys, null, null, null);
|
||||
return new SkinManager(Path.of("skins"), services, downloader, Runnable::run);
|
||||
}
|
||||
|
||||
/** Records GuiGraphicsExtractor calls. */
|
||||
public static final class Capture extends GuiGraphicsExtractor {
|
||||
private Capture() { super(null, null, 0, 0); }
|
||||
@@ -219,18 +279,35 @@ public final class VanillaTabListOracle {
|
||||
var player = alloc(LocalPlayer.class);
|
||||
put(player, LocalPlayer.class, "connection", connection);
|
||||
put(mc, Minecraft.class, "player", player);
|
||||
var user = alloc(net.minecraft.client.User.class);
|
||||
put(user, net.minecraft.client.User.class, "uuid", c.get("local").isJsonNull() ? new UUID(0, 0) : UUID.fromString(c.get("local").getAsString()));
|
||||
put(mc, Minecraft.class, "user", user);
|
||||
var skins = skinManager(c);
|
||||
put(mc, Minecraft.class, "skinManager", skins);
|
||||
for (var p : c.getAsJsonArray("players")) {
|
||||
var o = p.getAsJsonObject();
|
||||
var uuid = UUID.fromString(o.get("uuid").getAsString());
|
||||
var profile = new GameProfile(uuid, o.get("name").getAsString());
|
||||
var properties = com.google.common.collect.LinkedHashMultimap.<String, Property>create();
|
||||
if (o.has("textures") && !o.get("textures").isJsonNull()) {
|
||||
var t = o.getAsJsonObject("textures");
|
||||
var sig = t.get("signature");
|
||||
properties.put("textures", sig.isJsonNull()
|
||||
? new Property("textures", t.get("value").getAsString())
|
||||
: new Property("textures", t.get("value").getAsString(), sig.getAsString()));
|
||||
}
|
||||
var profile = new GameProfile(uuid, o.get("name").getAsString(), new PropertyMap(properties));
|
||||
// Let the lookup's unpacking and downloads run before the first frame,
|
||||
// as they would have by the time a player list shows.
|
||||
try {
|
||||
skins.get(profile).get(1, java.util.concurrent.TimeUnit.SECONDS);
|
||||
} catch (java.util.concurrent.TimeoutException pending) {
|
||||
}
|
||||
var info = new PlayerInfo(profile, false);
|
||||
put(info, PlayerInfo.class, "gameMode", GameType.byId(o.get("gameMode").getAsInt()));
|
||||
put(info, PlayerInfo.class, "latency", o.get("latency").getAsInt());
|
||||
if (!o.get("displayName").isJsonNull()) info.setTabListDisplayName(component(o.get("displayName")));
|
||||
info.setTabListOrder(o.get("listOrder").getAsInt());
|
||||
info.setShowHat(o.get("showHat").getAsBoolean());
|
||||
var skin = net.minecraft.client.resources.DefaultPlayerSkin.get(uuid);
|
||||
put(info, PlayerInfo.class, "skinLookup", (java.util.function.Supplier<?>) () -> skin);
|
||||
listed.add(info);
|
||||
if (o.get("inLevel").getAsBoolean()) {
|
||||
var entity = alloc(RemotePlayer.class);
|
||||
|
||||
Reference in New Issue
Block a user