#Why am I not getting items when I destroy stone?

1 messages · Page 1 of 1 (latest)

silent zinc
#

import { world, system, ItemStack } from "@minecraft/server";

world.beforeEvents.playerBreakBlock.subscribe((event) => {
const player = event.player;
const block = event.block;

if (block.type.id === "minecraft:stone") {
    
    player.sendMessage(`§a+1§r Cash`);
    player.runCommand(`give ${player.name} minecraft:emerald 1`);
}

});

thorn siren
silent zinc
thorn siren
#

Oh, delete the 'minecraft:'

errant zenith
# silent zinc import { world, system, ItemStack } from "@minecraft/server"; world.beforeEven...
import { world, system, ItemStack } from '@minecraft/server';

world.beforeEvents.playerBreakBlock.subscribe(({ block, player, itemStack }) => {
  const { container } = player.getComponent('inventory');

  if (block.typeId === 'minecraft:stone') {
    if (container.emptySlotsCount !== 0) system.run(() => container.addItem(new ItemStack('minecraft:emerald', 1)) );

    player.sendMessage('§a+§r Cash');
  }
});```
silent zinc
grand moss
errant zenith