use of net.minecraft.world.item.PlayerHeadItem in project SpongeCommon by SpongePowered.
the class SkullItemStackData method register.
// @formatter:off
public static void register(final DataProviderRegistrator registrator) {
registrator.asMutable(ItemStack.class).create(Keys.GAME_PROFILE).get(h -> {
final CompoundTag tag = h.getTagElement(Constants.Item.Skull.ITEM_SKULL_OWNER);
final GameProfile mcProfile = tag == null ? null : NbtUtils.readGameProfile(tag);
return mcProfile == null ? null : SpongeGameProfile.of(mcProfile);
}).set((h, v) -> {
final com.mojang.authlib.GameProfile mcProfile = SpongeGameProfile.toMcProfile(v);
final CompoundTag tag = NbtUtils.writeGameProfile(new CompoundTag(), mcProfile);
h.addTagElement(Constants.Item.Skull.ITEM_SKULL_OWNER, tag);
}).delete(h -> h.removeTagKey(Constants.Item.Skull.ITEM_SKULL_OWNER)).supports(h -> h.getItem() instanceof PlayerHeadItem);
}
Aggregations