Question [1.18.2] Custom heads with BlockPopulator apears as Steve head

  • After careful consideration and due to limited usage, we’ve made the decision to discontinue the PaperMC forums. Moving forward, we recommend using Hangar for plugin uploads, and for all other community discussions and support, please join us on Discord.
May 21, 2022
2
0
1
I try to generate custom trees and other structures with custom heads.
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.
 
May 21, 2022
2
0
1
After I post this I recognized the failure.
I missed region.setBlockState(pos, skull); because i thought the state is a reference and not a copy.