-
-
Save wizjany/51b646d1bdc3d31b0b74ffb4ffffc9e7 to your computer and use it in GitHub Desktop.
This file contains 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
@Override | |
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { | |
World world = (World) clicked.getExtent(); | |
EditSession editSession = session.createEditSession(player); | |
BlockVector3 blockPoint = clicked.toVector().toBlockPoint(); | |
BaseBlock block = editSession.getFullBlock(blockPoint); | |
TextComponent.Builder builder = TextComponent.builder(); | |
builder.append(TextComponent.of("@" + clicked.toVector().toBlockPoint() + ": ", TextColor.BLUE)); | |
builder.append(TextComponent.of(block.getBlockType().getName(), TextColor.YELLOW)); | |
builder.append(TextComponent.of(" (" + block + ") ", TextColor.GRAY) | |
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block state")))); | |
final OptionalInt internalId = BlockStateIdAccess.getBlockStateId(block.toImmutableState()); | |
if (internalId.isPresent()) { | |
builder.append(TextComponent.of(" (" + internalId.getAsInt() + ") ", TextColor.DARK_GRAY) | |
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Internal ID")))); | |
} | |
builder.append(TextComponent.of(" (" + world.getBlockLightLevel(blockPoint) + "/" | |
+ world.getBlockLightLevel(blockPoint.add(0, 1, 0)) + ")", TextColor.WHITE) | |
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Block Light/Light Above")))); | |
player.print(builder.build()); | |
if (block.hasNbtData()) { | |
player.print(BlockNbtComponent.builder() | |
.nbtPath("") | |
.interpret(true) | |
.absoluteWorldPos(blockPoint.getBlockX(), blockPoint.getBlockY(), blockPoint.getBlockZ()) | |
.build()); | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment