public class ExampleBlock extends Block { public ExampleBlock(Settings settings) { super(settings); } // 对于 1.20.5 以下版本,方法参数应该是“BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit” @Override public ActionResult onUse(World world, PlayerEntity player, BlockHitResult hit) { if (!world.isClient) { player.sendMessage(Text.literal("Hello, world!"), false); } return ActionResult.SUCCESS; } }