I try to generate custom trees and other structures with custom heads.
Here is the code:
The Problem is that every head is a steve head. The only exception that occured was, if the head is inside the spawn chunk radius then it is an alex head.
I debugged the code since a week and don't get the wrong place. I searched on the internet but there are no information about spawning an custom head in an chunkgenerator nor blockpopulator.
Here is the code:
Java:
BlockState state = region.getBlockState(pos);
// CompoundTag from net.minecraft.nbt with mojang-mappings
CompoundTag nbt = stateData[x + z * size.getBlockX() + y * size.getBlockX() * size.getBlockZ()];
if (nbt == null) {
Log.consoleDebug("NBT is null: %s".formatted(pos.toString()));
continue;
}
if (state instanceof Skull) {
Skull skull = (Skull) state;
// seperated for debugging purpose
CompoundTag skullOwner = nbt.getCompound("SkullOwner");
CompoundTag properties = skullOwner.getCompound("Properties");
ListTag textures = properties.getList("textures", CompoundTag.TAG_COMPOUND);
CompoundTag texture = textures.getCompound(0);
String textureBase64 =texture.getString("Value");
// PlayerProfile, ProfileProperty from com.destroystokyo.paper.profile
PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID(), "___");
profile.setProperty(
new ProfileProperty("textures", textureBase64)
);
skull.setPlayerProfile(profile);
region.scheduleBlockUpdate(pos);
}
The Problem is that every head is a steve head. The only exception that occured was, if the head is inside the spawn chunk radius then it is an alex head.
I debugged the code since a week and don't get the wrong place. I searched on the internet but there are no information about spawning an custom head in an chunkgenerator nor blockpopulator.