@@ -133,7 +133,7 @@ public static void apply(Expression expression)
133
133
{
134
134
return ListValue .wrap (cc .registry (Registries .SOUND_EVENT ).holders ().map (soundEventReference -> ValueConversions .of (soundEventReference .key ().location ())));
135
135
}
136
- String rawString = lv .getFirst ( ).getString ();
136
+ String rawString = lv .get ( 0 ).getString ();
137
137
ResourceLocation soundName = InputValidator .identifierOf (rawString );
138
138
Vector3Argument locator = Vector3Argument .findIn (lv , 1 );
139
139
@@ -181,7 +181,7 @@ public static void apply(Expression expression)
181
181
MinecraftServer ms = cc .server ();
182
182
ServerLevel world = cc .level ();
183
183
Vector3Argument locator = Vector3Argument .findIn (lv , 1 );
184
- String particleName = lv .getFirst ( ).getString ();
184
+ String particleName = lv .get ( 0 ).getString ();
185
185
int count = 10 ;
186
186
double speed = 0 ;
187
187
float spread = 0.5f ;
@@ -226,7 +226,7 @@ public static void apply(Expression expression)
226
226
{
227
227
CarpetContext cc = (CarpetContext ) c ;
228
228
ServerLevel world = cc .level ();
229
- String particleName = lv .getFirst ( ).getString ();
229
+ String particleName = lv .get ( 0 ).getString ();
230
230
ParticleOptions particle = ShapeDispatcher .getParticleData (particleName , world .registryAccess ());
231
231
Vector3Argument pos1 = Vector3Argument .findIn (lv , 1 );
232
232
Vector3Argument pos2 = Vector3Argument .findIn (lv , pos1 .offset );
@@ -264,13 +264,13 @@ public static void apply(Expression expression)
264
264
));
265
265
});
266
266
267
- expression .addContextFunction ("item_display_name" , 1 , (c , t , lv ) -> new FormattedTextValue (ValueConversions .getItemStackFromValue (lv .getFirst ( ), false , ((CarpetContext ) c ).registryAccess ()).getHoverName ()));
267
+ expression .addContextFunction ("item_display_name" , 1 , (c , t , lv ) -> new FormattedTextValue (ValueConversions .getItemStackFromValue (lv .get ( 0 ), false , ((CarpetContext ) c ).registryAccess ()).getHoverName ()));
268
268
269
269
expression .addContextFunction ("particle_box" , -1 , (c , t , lv ) ->
270
270
{
271
271
CarpetContext cc = (CarpetContext ) c ;
272
272
ServerLevel world = cc .level ();
273
- String particleName = lv .getFirst ( ).getString ();
273
+ String particleName = lv .get ( 0 ).getString ();
274
274
ParticleOptions particle = ShapeDispatcher .getParticleData (particleName , world .registryAccess ());
275
275
Vector3Argument pos1 = Vector3Argument .findIn (lv , 1 );
276
276
Vector3Argument pos2 = Vector3Argument .findIn (lv , pos1 .offset );
@@ -325,7 +325,7 @@ public static void apply(Expression expression)
325
325
List <ShapeDispatcher .ShapeWithConfig > shapes = new ArrayList <>();
326
326
if (lv .size () == 1 ) // bulk
327
327
{
328
- Value specLoad = lv .getFirst ( );
328
+ Value specLoad = lv .get ( 0 );
329
329
if (!(specLoad instanceof final ListValue spec ))
330
330
{
331
331
throw new InternalExpressionException ("In bulk mode - shapes need to be provided as a list of shape specs" );
@@ -359,7 +359,7 @@ public static void apply(Expression expression)
359
359
Component name ;
360
360
try
361
361
{
362
- Value nameValue = lv .getFirst ( );
362
+ Value nameValue = lv .get ( 0 );
363
363
name = nameValue .isNull () ? null : FormattedTextValue .getTextByValue (nameValue );
364
364
pointLocator = Vector3Argument .findIn (lv , 1 , true , false );
365
365
if (lv .size () > pointLocator .offset )
@@ -464,11 +464,11 @@ else if (!interactable && targetBlock == null)
464
464
{
465
465
return Value .TRUE ;
466
466
}
467
- if (lv .getFirst ( ).isNull ())
467
+ if (lv .get ( 0 ).isNull ())
468
468
{
469
469
return Value .FALSE ;
470
470
}
471
- Tag source = ((NBTSerializableValue ) (NBTSerializableValue .fromValue (lv .getFirst ( )))).getTag ();
471
+ Tag source = ((NBTSerializableValue ) (NBTSerializableValue .fromValue (lv .get ( 0 )))).getTag ();
472
472
Tag match = ((NBTSerializableValue ) (NBTSerializableValue .fromValue (lv .get (1 )))).getTag ();
473
473
return BooleanValue .of (NbtUtils .compareNbt (match , source , numParam == 2 || lv .get (2 ).getBoolean ()));
474
474
});
@@ -479,7 +479,7 @@ else if (!interactable && targetBlock == null)
479
479
{
480
480
throw new InternalExpressionException ("'encode_nbt' requires 1 or 2 parameters" );
481
481
}
482
- Value v = lv .getFirst ( );
482
+ Value v = lv .get ( 0 );
483
483
boolean force = (argSize > 1 ) && lv .get (1 ).getBoolean ();
484
484
Tag tag ;
485
485
try
@@ -503,7 +503,7 @@ else if (!interactable && targetBlock == null)
503
503
CarpetContext cc = (CarpetContext ) c ;
504
504
CommandSourceStack s = cc .source ();
505
505
MinecraftServer server = s .getServer ();
506
- Value res = lv .getFirst ( );
506
+ Value res = lv .get ( 0 );
507
507
List <CommandSourceStack > targets = null ;
508
508
if (lv .size () == 2 )
509
509
{
@@ -542,7 +542,7 @@ else if (!interactable && targetBlock == null)
542
542
{
543
543
throw new InternalExpressionException ("'display_title' needs at least a target, type and message, and optionally times" );
544
544
}
545
- Value pVal = lv .getFirst ( );
545
+ Value pVal = lv .get ( 0 );
546
546
if (!(pVal instanceof ListValue ))
547
547
{
548
548
pVal = ListValue .of (pVal );
@@ -671,7 +671,7 @@ else if (!interactable && targetBlock == null)
671
671
{
672
672
throw new InternalExpressionException ("'format' requires at least one component" );
673
673
}
674
- if (values .getFirst ( ) instanceof final ListValue list && values .size () == 1 )
674
+ if (values .get ( 0 ) instanceof final ListValue list && values .size () == 1 )
675
675
{
676
676
values = list .getItems ();
677
677
}
@@ -687,7 +687,7 @@ else if (!interactable && targetBlock == null)
687
687
List <Component > output = new ArrayList <>();
688
688
s .getServer ().getCommands ().performPrefixedCommand (
689
689
new SnoopyCommandSource (s , error , output ),
690
- lv .getFirst ( ).getString ());
690
+ lv .get ( 0 ).getString ());
691
691
return ListValue .of (
692
692
NumericValue .ZERO ,
693
693
ListValue .wrap (output .stream ().map (FormattedTextValue ::new )),
@@ -726,7 +726,7 @@ else if (!interactable && targetBlock == null)
726
726
Value time = new NumericValue (((CarpetContext ) c ).level ().getDayTime ());
727
727
if (!lv .isEmpty ())
728
728
{
729
- long newTime = NumericValue .asNumber (lv .getFirst ( )).getLong ();
729
+ long newTime = NumericValue .asNumber (lv .get ( 0 )).getLong ();
730
730
if (newTime < 0 )
731
731
{
732
732
newTime = 0 ;
@@ -765,7 +765,7 @@ else if (!interactable && targetBlock == null)
765
765
Vanilla .MinecraftServer_forceTick (server , () -> System .nanoTime () - scriptServer .tickStart < 50000000L );
766
766
if (!lv .isEmpty ())
767
767
{
768
- long msTotal = NumericValue .asNumber (lv .getFirst ( )).getLong ();
768
+ long msTotal = NumericValue .asNumber (lv .get ( 0 )).getLong ();
769
769
long endExpected = scriptServer .tickStart + msTotal * 1000000L ;
770
770
long wait = endExpected - System .nanoTime ();
771
771
if (wait > 0L )
@@ -825,7 +825,7 @@ else if (!interactable && targetBlock == null)
825
825
// lazy due to passthrough and context changing ability
826
826
expression .addLazyFunction ("in_dimension" , 2 , (c , t , lv ) -> {
827
827
CommandSourceStack outerSource = ((CarpetContext ) c ).source ();
828
- Value dimensionValue = lv .getFirst ( ).evalValue (c );
828
+ Value dimensionValue = lv .get ( 0 ).evalValue (c );
829
829
Level world = ValueConversions .dimFromValue (dimensionValue , outerSource .getServer ());
830
830
if (world == outerSource .getLevel ())
831
831
{
@@ -886,7 +886,7 @@ else if (!interactable && targetBlock == null)
886
886
{
887
887
throw new InternalExpressionException ("'schedule' should have at least 2 arguments, delay and call name" );
888
888
}
889
- long delay = NumericValue .asNumber (lv .getFirst ( )).getLong ();
889
+ long delay = NumericValue .asNumber (lv .get ( 0 )).getLong ();
890
890
891
891
FunctionArgument functionArgument = FunctionArgument .findIn (c , expression .module , lv , 1 , false , false );
892
892
((CarpetScriptServer )c .host .scriptServer ()).events .scheduleCall (
@@ -904,12 +904,12 @@ else if (!interactable && targetBlock == null)
904
904
905
905
if (lv .size () == 1 )
906
906
{
907
- res = lv .getFirst ( );
907
+ res = lv .get ( 0 );
908
908
CarpetScriptServer .LOG .info (res .getString ());
909
909
}
910
910
else if (lv .size () == 2 )
911
911
{
912
- String level = lv .getFirst ( ).getString ().toLowerCase (Locale .ROOT );
912
+ String level = lv .get ( 0 ).getString ().toLowerCase (Locale .ROOT );
913
913
res = lv .get (1 );
914
914
switch (level )
915
915
{
@@ -1018,7 +1018,7 @@ else if (fdesc.type == FileArgument.Type.JSON)
1018
1018
if (!lv .isEmpty ())
1019
1019
{
1020
1020
c .host .issueDeprecation ("load_app_data(...) with arguments" );
1021
- String resource = recognizeResource (lv .getFirst ( ), false );
1021
+ String resource = recognizeResource (lv .get ( 0 ), false );
1022
1022
boolean shared = lv .size () > 1 && lv .get (1 ).getBoolean ();
1023
1023
fdesc = new FileArgument (resource , FileArgument .Type .NBT , null , false , shared , FileArgument .Reason .READ , c .host );
1024
1024
}
@@ -1031,7 +1031,7 @@ else if (fdesc.type == FileArgument.Type.JSON)
1031
1031
{
1032
1032
throw new InternalExpressionException ("'store_app_data' needs NBT tag and an optional file" );
1033
1033
}
1034
- Value val = lv .getFirst ( );
1034
+ Value val = lv .get ( 0 );
1035
1035
FileArgument fdesc = new FileArgument (null , FileArgument .Type .NBT , null , false , false , FileArgument .Reason .CREATE , c .host );
1036
1036
if (lv .size () > 1 )
1037
1037
{
@@ -1049,7 +1049,7 @@ else if (fdesc.type == FileArgument.Type.JSON)
1049
1049
expression .addContextFunction ("statistic" , 3 , (c , t , lv ) ->
1050
1050
{
1051
1051
CarpetContext cc = (CarpetContext ) c ;
1052
- ServerPlayer player = EntityValue .getPlayerByValue (cc .server (), lv .getFirst ( ));
1052
+ ServerPlayer player = EntityValue .getPlayerByValue (cc .server (), lv .get ( 0 ));
1053
1053
if (player == null )
1054
1054
{
1055
1055
return Value .NULL ;
@@ -1078,7 +1078,7 @@ else if (fdesc.type == FileArgument.Type.JSON)
1078
1078
{
1079
1079
throw new InternalExpressionException ("'handle_event' requires at least two arguments, event name, and a callback" );
1080
1080
}
1081
- String event = lv .getFirst ( ).getString ();
1081
+ String event = lv .get ( 0 ).getString ();
1082
1082
FunctionArgument callback = FunctionArgument .findIn (c , expression .module , lv , 1 , true , false );
1083
1083
CarpetScriptHost host = ((CarpetScriptHost ) c .host );
1084
1084
if (callback .function == null )
@@ -1097,7 +1097,7 @@ else if (fdesc.type == FileArgument.Type.JSON)
1097
1097
}
1098
1098
CarpetContext cc = (CarpetContext ) c ;
1099
1099
CarpetScriptServer server = ((CarpetScriptHost ) c .host ).scriptServer ();
1100
- String eventName = lv .getFirst ( ).getString ();
1100
+ String eventName = lv .get ( 0 ).getString ();
1101
1101
// no such event yet
1102
1102
if (CarpetEventServer .Event .getEvent (eventName , server ) == null )
1103
1103
{
@@ -1135,7 +1135,7 @@ else if (fdesc.type == FileArgument.Type.JSON)
1135
1135
{
1136
1136
return ListValue .wrap (storage .keys ().map (NBTSerializableValue ::nameFromRegistryId ));
1137
1137
}
1138
- String key = lv .getFirst ( ).getString ();
1138
+ String key = lv .get ( 0 ).getString ();
1139
1139
CompoundTag oldNbt = storage .get (InputValidator .identifierOf (key ));
1140
1140
if (lv .size () == 2 )
1141
1141
{
@@ -1151,7 +1151,7 @@ else if (fdesc.type == FileArgument.Type.JSON)
1151
1151
// script run create_datapack('foo', {'foo' -> {'bar.json' -> {'c' -> true,'d' -> false,'e' -> {'foo' -> [1,2,3]},'a' -> 'foobar','b' -> 5}}})
1152
1152
expression .addContextFunction ("create_datapack" , 2 , (c , t , lv ) -> {
1153
1153
CarpetContext cc = (CarpetContext ) c ;
1154
- String origName = lv .getFirst ( ).getString ();
1154
+ String origName = lv .get ( 0 ).getString ();
1155
1155
String name = InputValidator .validateSimpleString (origName , true );
1156
1156
MinecraftServer server = cc .server ();
1157
1157
for (String dpName : server .getPackRepository ().getAvailableIds ())
0 commit comments