diff --git a/docs/scarpet/api/Entities.md b/docs/scarpet/api/Entities.md index bbd2872e..5e013034 100644 --- a/docs/scarpet/api/Entities.md +++ b/docs/scarpet/api/Entities.md @@ -177,7 +177,7 @@ Returns `true` if en entity is standing on firm ground and falling down due to t ### `query(e, 'name'), query(e, 'display_name'), query(e, 'custom_name'), query(e, 'type')` -String of entity name +String of entity name or formatted text in the case of `display_name`
 query(e,'name')  => Leatherworker
diff --git a/docs/scarpet/language/Containers.md b/docs/scarpet/language/Containers.md
index 07d6993a..882f4f7f 100644
--- a/docs/scarpet/language/Containers.md
+++ b/docs/scarpet/language/Containers.md
@@ -187,10 +187,10 @@ other parts. In that case consecutive calls to `slice` will refer to index `0` t
 cannot go back nor track where they are in the sequence (see examples).
 
 
-slice([0,1,2,3,4,5], 1, 3)  => [1, 2, 3]
+slice([0,1,2,3,4,5], 1, 3)  => [1, 2]
 slice('foobar', 0, 1)  => 'f'
 slice('foobar', 3)  => 'bar'
-slice(range(10), 3, 5)  => [3, 4, 5]
+slice(range(10), 3, 5)  => [3, 4]
 slice(range(10), 5)  => [5, 6, 7, 8, 9]
 r = range(100); [slice(r, 5, 7), slice(r, 1, 3)]  => [[5, 6], [8, 9]]
 
diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index a41a478d..6a1ab764 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -532,6 +532,14 @@ public class CarpetSettings ) public static int maxEntityCollisions = 0; + @Rule( + desc = "Customizable server list ping (Multiplayer menu) playerlist sample limit", + options = {"0", "12", "20", "40"}, + category = CREATIVE, + strict = false, + validate = Validator.NONNEGATIVE_NUMBER.class + ) + public static int pingPlayerListLimit = 12; /* @Rule( diff --git a/src/main/java/carpet/mixins/MinecraftServer_pingPlayerSampleLimit.java b/src/main/java/carpet/mixins/MinecraftServer_pingPlayerSampleLimit.java new file mode 100644 index 00000000..79e2e27d --- /dev/null +++ b/src/main/java/carpet/mixins/MinecraftServer_pingPlayerSampleLimit.java @@ -0,0 +1,19 @@ +package carpet.mixins; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +import carpet.CarpetSettings; +import net.minecraft.server.MinecraftServer; + +@Mixin(MinecraftServer.class) +public abstract class MinecraftServer_pingPlayerSampleLimit +{ + + @ModifyConstant(method = "tick", constant = @Constant(intValue = 12), require = 0, allow = 1) + private int modifyPlayerSampleLimit(int value) + { + return CarpetSettings.pingPlayerListLimit; + } +} diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 0a1c3506..0e08f7a0 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -416,7 +416,7 @@ public class EntityValue extends Value put("motion_z", (e, a) -> new NumericValue(e.getVelocity().z)); put("on_ground", (e, a) -> new NumericValue(e.isOnGround())); put("name", (e, a) -> new StringValue(e.getName().getString())); - put("display_name", (e, a) -> new StringValue(e.getDisplayName().getString())); + put("display_name", (e, a) -> new FormattedTextValue(e.getDisplayName())); put("command_name", (e, a) -> new StringValue(e.getEntityName())); put("custom_name", (e, a) -> e.hasCustomName()?new StringValue(e.getCustomName().getString()):Value.NULL); put("type", (e, a) -> new StringValue(nameFromRegistryId(Registry.ENTITY_TYPE.getId(e.getType())))); diff --git a/src/main/java/carpet/script/value/ListValue.java b/src/main/java/carpet/script/value/ListValue.java index 7fd693eb..de316668 100644 --- a/src/main/java/carpet/script/value/ListValue.java +++ b/src/main/java/carpet/script/value/ListValue.java @@ -341,7 +341,7 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf int from = normalizeIndex(fromDesc, size); if (toDesc == null) return new ListValue((Collection) getItems().subList(from, size)); - int to = normalizeIndex(toDesc, size); + int to = normalizeIndex(toDesc, size+1); if (from > to) return ListValue.of(); return new ListValue((Collection) getItems().subList(from, to)); diff --git a/src/main/java/carpet/script/value/Value.java b/src/main/java/carpet/script/value/Value.java index 5f228c7d..5548d83f 100644 --- a/src/main/java/carpet/script/value/Value.java +++ b/src/main/java/carpet/script/value/Value.java @@ -186,7 +186,7 @@ public abstract class Value implements Comparable, Cloneable int size = value.length(); int from = ListValue.normalizeIndex(fromDesc, size); if (toDesc == null) return new StringValue(value.substring(from)); - int to = ListValue.normalizeIndex(toDesc, size); + int to = ListValue.normalizeIndex(toDesc, size+1); if (from > to) return StringValue.EMPTY; return new StringValue(value.substring(from, to)); } diff --git a/src/main/resources/assets/carpet/scripts/camera.sc b/src/main/resources/assets/carpet/scripts/camera.sc index 7d146cdd..8f21ced5 100644 --- a/src/main/resources/assets/carpet/scripts/camera.sc +++ b/src/main/resources/assets/carpet/scripts/camera.sc @@ -1,4 +1,4 @@ -__command() -> +_command() -> ( print('camera: scarpet app.'); print('-------------------'); @@ -11,7 +11,7 @@ __command() -> print(' "/camera place_player - Move player to the selected point'); print(' "/camera move" - Move the selected point to players location'); print(' "/camera duration " - Set new selected path duration'); - print(' "/camera split_point>" - Split selected path in half.'); + print(' "/camera split_point" - Split selected path in half.'); print(' "/camera delete_point" - Remove current key point'); print(' "/camera trim_path" - Remove all key points from selected up'); print(''); @@ -57,6 +57,47 @@ __command() -> print(''); null ); +__config() ->{ + 'commands'->{ + ''->'_command', + ''->'_call', + 'add '->'add', + 'prepend '->'prepend', + 'duration ', + 'save_as '->'save_as', + 'load '->'load', + 'interpolation '->['__interpolation',true], + 'interpolation gauss'->['__interpolation','gauss',true], + 'interpolation gauss '->_(float)->(__interpolation('gauss_'+str(float),true)), + 'repeat '->'repeat', + 'stretch '->'stretch' + }, + 'arguments'->{ + 'seconds'->{'type'->'int','suggest'->[]}, + 'last_delay'->{'type'->'int','suggest'->[]}, + 'name'->{'type'->'string','suggest'->[]}, + 'interpolation'->{'type'->'term','options'->['linear','catmull_rom']} + 'factor'->{'type'->'int','min'->25,'max'->'400'}, + 'command'->{'type'->'term','options'->[ + 'start', + 'clear', + 'select', + 'place_player', + 'move', + 'split_point', + 'delete_point', + 'trim_path', + 'transpose', + 'play', + 'show', + 'hide', + 'prefer_smooth_play', + 'prefer_synced_play' + ]} + } +}; + +_call(command)->call(command); global_points = null; global_dimension = null; @@ -150,7 +191,6 @@ __assert_point_selected(validator) -> ); //select a custom interpolation method -interpolation(method) -> __interpolation(method, true); __interpolation(method, verbose) -> ( __prepare_path_if_needed() -> __prepare_path_if_needed_generic(); @@ -159,7 +199,7 @@ __interpolation(method, verbose) -> // or optionally __prepare_path_if_needed, if path is inefficient to compute point by point global_interpolator = if ( method == 'linear', '__interpolator_linear', - method == 'cr', '__interpolator_cr', + method == 'catmull_rom', '__interpolator_cr', method == 'gauss', _(s, p) -> __interpolator_gauB(s, p, 0), method ~ '^gauss_', ( @@ -167,8 +207,7 @@ __interpolation(method, verbose) -> type = replace(type,'_','.'); variance = round(60*number(type)); _(s, p, outer(variance)) -> __interpolator_gauB(s, p, variance); - ), - exit('Choose one of the following methods: linear, gauss, gauss_, cr') + ) ); __update(); if(verbose, 'Interpolation changed to '+method, ''); @@ -216,9 +255,6 @@ repeat(times, last_section_delay) -> stretch(percentage) -> ( if (err = __is_not_valid_for_motion(), exit(err)); - if (percentage < 25 || percentage > 400, - exit('path speed can only be speed, or slowed down 4 times. Re-call command for larger changes') - ); ratio = percentage/100; previous_path_length = global_points:(-1):1; for(global_points, _:1 = _:1*ratio ); @@ -660,4 +696,4 @@ __on_close() -> ( global_playing_path = false; global_showing_path = false; -); +); \ No newline at end of file diff --git a/src/main/resources/carpet.mixins.json b/src/main/resources/carpet.mixins.json index bcbf958c..e6174d9d 100644 --- a/src/main/resources/carpet.mixins.json +++ b/src/main/resources/carpet.mixins.json @@ -24,6 +24,7 @@ "ServerPlayNetworkHandler_interactionUpdatesMixin", "ServerMetadata_motdMixin", + "MinecraftServer_pingPlayerSampleLimit", "MinecraftServer_coreMixin",