Skip to content

Instantly share code, notes, and snippets.

View ThatPotatoDev's full-sized avatar

ThatPotatoDev ThatPotatoDev

View GitHub Profile
public void handlePickBlock(@NotNull PlayerPickBlockEvent event) {
var player = event.getPlayer();
if (player.getGameMode() != GameMode.CREATIVE) return; // Sanity
var world = MapWorld.forPlayerOptional(player);
if (world == null || !world.canEdit(player)) return; // Sanity
// First try to get the block from the item registry
var block = event.getBlock();
var itemStack = world.itemRegistry().getItemStack(block, event.isIncludeData());