User Tools

Site Tools


tutorial:command_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
tutorial:command_examples [2022/08/08 02:25] – created solidblocktutorial:command_examples [2023/11/18 13:06] (current) – [/giveMeDiamond] solidblock
Line 40: Line 40:
 ===== /giveMeDiamond ===== ===== /giveMeDiamond =====
  
-First the basic code where we register "giveMeDiamond" as a literal and then an executes block to tell the dispatcher which method to run.+First the basic code where we register "giveMeDiamond" as a literal and then an ''executes'' block to tell the dispatcher which method to run.
  
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
Line 62: Line 62:
 <code java [enable_line_numbers="true"]> <code java [enable_line_numbers="true"]>
     if(!player.inventory.insertStack(new ItemStack(Items.DIAMOND))){     if(!player.inventory.insertStack(new ItemStack(Items.DIAMOND))){
-        throw new SimpleCommandExceptionType(Text.translatable("inventory.isfull")).create();+        throw new CommandException(Text.translatable("commands.giveMeDiamond.isfull"));
     }     }
 +    source.sendFeedback(() -> Text.translatable("commands.giveMeDiamond.success", self.getDisplayName()), true);
  
     return 1;     return 1;
tutorial/command_examples.1659925509.txt.gz · Last modified: 2022/08/08 02:25 by solidblock