Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityHuman with custom skin bug #1759

Open
Bestaford opened this issue Feb 6, 2021 · 2 comments
Open

EntityHuman with custom skin bug #1759

Bestaford opened this issue Feb 6, 2021 · 2 comments

Comments

@Bestaford
Copy link

Expected Behavior

EntityHuman with specified skin (with custom geometry and skin bytes data) works

Actual Behavior

EntityHuman spawns but without any skin

Steps to Reproduce

Convert .json geometry and .png texture to byte array, create skin, fill Skin CompoundTag and spawn EntityHuman

try {
            Path path = getDataFolder().toPath();
            CompoundTag nbt = Entity.getDefaultNBT(spawn);
            Skin skin = new Skin();
            skin.setSkinId("coin");
            skin.setSkinData(ImageIO.read(path.resolve("model-texture.png").toFile()));
            skin.setGeometryName("geometry.coin-model");
            skin.setGeometryData(new String(Files.readAllBytes(path.resolve("model-geometry.json")), StandardCharsets.UTF_8));
            CompoundTag skinTag = new CompoundTag()
                    .putByteArray("Data", skin.getSkinData().data)
                    .putInt("SkinImageWidth", skin.getSkinData().width)
                    .putInt("SkinImageHeight", skin.getSkinData().height)
                    .putString("ModelId", skin.getSkinId())
                    .putString("CapeId", skin.getCapeId())
                    .putByteArray("CapeData", skin.getCapeData().data)
                    .putInt("CapeImageWidth", skin.getCapeData().width)
                    .putInt("CapeImageHeight", skin.getCapeData().height)
                    .putByteArray("SkinResourcePatch", skin.getSkinResourcePatch().getBytes(StandardCharsets.UTF_8))
                    .putByteArray("GeometryData", skin.getGeometryData().getBytes(StandardCharsets.UTF_8))
                    .putByteArray("AnimationData", skin.getAnimationData().getBytes(StandardCharsets.UTF_8))
                    .putBoolean("PremiumSkin", skin.isPremium())
                    .putBoolean("PersonaSkin", skin.isPersona())
                    .putBoolean("CapeOnClassicSkin", skin.isCapeOnClassic());
            nbt.putString("NameTag", "geometry.coin-model");
            nbt.putCompound("Skin", skinTag);
            EntityHuman model = new EntityHuman(spawn.getChunk(), nbt);
            model.spawnToAll();
        } catch (Exception exception) {
            getLogger().error(exception.getMessage());
        }

Note

I made sure model is correctly and i got the skin data correctly. To check it i use SkinChanger plugin, put my model, join server and change my own skin to this model:
Снимок экрана (118)

@lt-name
Copy link
Contributor

lt-name commented Feb 7, 2021

Try this

Skin skin = new Skin();
skin.setTrusted(true);
skin.setSkinId("coin");
skin.setSkinData(ImageIO.read(path.resolve("model-texture.png").toFile()));
skin.setGeometryName("geometry.coin-model");
skin.setGeometryData(new String(Files.readAllBytes(path.resolve("model-geometry.json")), StandardCharsets.UTF_8));
EntityHuman model = new EntityHuman(spawn.getChunk(), nbt);
model.setSkin(skin);
model.spawnToAll();

@Bestaford
Copy link
Author

What is difference? Trusted skin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants