Created
September 21, 2025 12:35
-
-
Save mworzala/0f6d826ffd9c7916b37ba0d390156360 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package net.hollowcube.mapmaker.map.block.handler; | |
| import net.kyori.adventure.key.Key; | |
| import net.kyori.adventure.nbt.BinaryTag; | |
| import net.minestom.server.codec.Transcoder; | |
| import net.minestom.server.component.DataComponents; | |
| import net.minestom.server.instance.block.Block; | |
| import net.minestom.server.instance.block.BlockHandler; | |
| import net.minestom.server.item.component.HeadProfile; | |
| import net.minestom.server.tag.Tag; | |
| import org.jetbrains.annotations.NotNull; | |
| import org.jetbrains.annotations.Nullable; | |
| import java.util.Collection; | |
| import java.util.List; | |
| public class PlayerHeadBlockHandler implements BlockHandler { | |
| public static final Tag<BinaryTag> PROFILE = Tag.NBT("profile"); | |
| public static final Key ID = Key.key("minecraft:skull"); | |
| public static @Nullable HeadProfile extractProfile(@NotNull Block block) { | |
| var profile = block.getTag(PROFILE); | |
| if (profile == null) return null; | |
| return DataComponents.PROFILE.decode(Transcoder.NBT, profile).orElseThrow(); | |
| } | |
| PlayerHeadBlockHandler() { | |
| } | |
| @Override | |
| public @NotNull Key getKey() { | |
| return ID; | |
| } | |
| @Override | |
| public byte getBlockEntityAction() { | |
| return 15; | |
| } | |
| @Override | |
| public @NotNull Collection<Tag<?>> getBlockEntityTags() { | |
| return List.of(PROFILE); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment