@@ -52,7 +52,7 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
5252 }, "Returns the current Minecraft version string." , args -> {}, Argtypes .STRING );
5353
5454 builder .add ("say" , args -> {
55- String s = MetamethodImpl . tostring ( args .arg1 () );
55+ String s = args .nextString ( );
5656
5757 for (ServerPlayer spe : script .getSource ().getServer ().getPlayerList ().getPlayers ()) {
5858 spe .sendSystemMessage (Component .literal (s ), false );
@@ -67,7 +67,7 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
6767 }, Argtypes .NIL );
6868
6969 builder .add ("command" , args -> {
70- String s = MetamethodImpl . tostring ( args .arg1 () );
70+ String s = args .nextString ( );
7171 var source = script .getSource ().getServer ().createCommandSourceStack ();
7272 var cmd = parseCommand (s , source );
7373 int result = executeCommand (cmd , source );
@@ -77,10 +77,10 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
7777 }, Argtypes .INTEGER );
7878
7979 builder .add ("note" , args -> {
80- Note note = ScriptEnums .NOTE .fromKey (MetamethodImpl . tostring ( args .arg ( 1 ) ));
81- Instrument instrument = ScriptEnums .INSTRUMENT .fromKey (MetamethodImpl . tostring ( args .arg ( 2 ) ));
82- Vec3 pos = ScriptObjects .VEC3D .toThing (args .arg ( 3 ). checktable (), script .getSource (), this .script );
83- boolean particle = args .arg ( 4 ). or ( LuaBoolean . TRUE ). checkboolean ( );
80+ Note note = ScriptEnums .NOTE .fromKey (args .nextString ( ));
81+ Instrument instrument = ScriptEnums .INSTRUMENT .fromKey (args .nextString ( ));
82+ Vec3 pos = ScriptObjects .VEC3D .toThing (args .nextTable (), script .getSource (), this .script );
83+ boolean particle = args .nextBoolean ( true );
8484
8585 ServerLevel world = script .getSource ().getLevel ();
8686
@@ -102,7 +102,7 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
102102 }, Argtypes .NIL );
103103
104104 builder .add ("sleep" , args -> {
105- float seconds = args .arg1 (). tofloat ();
105+ float seconds = args .nextFloat ();
106106 try {
107107 Thread .sleep ((long ) (seconds * 1000 ));
108108 } catch (InterruptedException e ) {
@@ -117,7 +117,7 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
117117
118118 apiBuilder .addGroup ("entities" , builder -> {
119119 builder .add ("get_player_from_selector" , args -> {
120- String selector = MetamethodImpl . tostring ( args .arg1 () );
120+ String selector = args .nextString ( );
121121 EntitySelectorParser reader = new EntitySelectorParser (new StringReader (selector ), true );
122122 try {
123123 EntitySelector s = reader .parse ();
@@ -136,7 +136,7 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
136136 }, ScriptObjects .PLAYER );
137137
138138 builder .add ("get_entity_from_selector" , args -> {
139- String selector = MetamethodImpl . tostring ( args .arg1 () );
139+ String selector = args .nextString ( );
140140 EntitySelectorParser reader = new EntitySelectorParser (new StringReader (selector ), true );
141141 try {
142142 EntitySelector s = reader .parse ();
@@ -155,7 +155,7 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
155155 }, ScriptObjects .ENTITY );
156156
157157 builder .add ("get_entities_from_selector" , args -> {
158- String selector = MetamethodImpl . tostring ( args .arg1 () );
158+ String selector = args .nextString ( );
159159 EntitySelectorParser reader = new EntitySelectorParser (new StringReader (selector ), true );
160160 try {
161161 EntitySelector s = reader .parse ();
@@ -176,15 +176,15 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
176176 apiBuilder .addGroup ("registry" , builder -> {
177177
178178 builder .add ("item" , args -> {
179- Identifier id = Identifier .parse (MetamethodImpl . tostring ( args .arg1 () ));
179+ Identifier id = Identifier .parse (args .nextString ( ));
180180 Item item = BuiltInRegistries .ITEM .getValue (id );
181181 return LuaTableBuilder .provide (ScriptObjects .ITEM , item , script );
182182 }, "Fetches an item type from the registry." , args -> {
183183 args .add ("id" , Argtypes .STRING , "Identifier of the item type." );
184184 }, ScriptObjects .ITEM );
185185
186186 builder .add ("block" , args -> {
187- Identifier id = Identifier .parse (MetamethodImpl . tostring ( args .arg1 () ));
187+ Identifier id = Identifier .parse (args .nextString ( ));
188188 Block block = BuiltInRegistries .BLOCK .getValue (id );
189189 return LuaTableBuilder .provide (ScriptObjects .BLOCK , block , script );
190190 }, "Fetches an block type from the registry." , args -> {
@@ -196,8 +196,8 @@ public void addFunctions(ScriptApiBuilder apiBuilder) {
196196 apiBuilder .addGroup ("object" , builder -> {
197197
198198 builder .add ("itemstack" , args -> {
199- Item item = ScriptObjects . ITEM . toThing ( args .arg1 (). checktable () , script .getSource (), script );
200- int count = args .arg ( 2 ). toint ();
199+ Item item = args .nextScriptObject ( ScriptObjects . ITEM , script .getSource (), script );
200+ int count = args .nextInt ();
201201 ItemStack stack = new ItemStack (item , count );
202202 return LuaTableBuilder .provide (ScriptObjects .ITEM_STACK , stack , script );
203203 }, "Creates an ItemStack from an item and count." , args -> {
0 commit comments