Entity with custom skin and geometry

How to create entity with custom skin and geometry? i tried that, but skin just doesnt applies

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());
        }
1 Like

Hello! Welcome!

I remember having a long talk with an user in our discord about custom skin models, he was trying to emulate custom player heads similarly to what we can do in Java Edition, and he succeed in this job.

If you share a model JSON and a texture PNG that you are trying to use, I can create a working example or show what is wrong with the model.

1 Like