diff --git a/docs/scarpet/Full.md b/docs/scarpet/Full.md index 3a04f299..e45949d4 100644 --- a/docs/scarpet/Full.md +++ b/docs/scarpet/Full.md @@ -2502,6 +2502,10 @@ Returns `null` if the argument is not a player, otherwise: * `shadow`: any carpet-shadowed real player * `realms`: ? +### `query(e,'ping')` + +Player's ping in milliseconds, or `null` if its not a player. + ### `query(e,'permission_level')` Player's permission level, or `null` if not applicable for this entity. diff --git a/docs/scarpet/api/Entities.md b/docs/scarpet/api/Entities.md index 623fd37c..5fec0d0b 100644 --- a/docs/scarpet/api/Entities.md +++ b/docs/scarpet/api/Entities.md @@ -265,6 +265,10 @@ Returns `null` if the argument is not a player, otherwise: * `shadow`: any carpet-shadowed real player * `realms`: ? +### `query(e,'ping')` + +Player's ping in milliseconds, or `null` if its not a player. + ### `query(e,'permission_level')` Player's permission level, or `null` if not applicable for this entity. diff --git a/gradle.properties b/gradle.properties index 96c95b15..02014a82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.7.8+build.189 # Mod Properties - mod_version = 1.3.16+v200325 + mod_version = 1.3.17+v200401 maven_group = carpet archives_base_name = fabric-carpet diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index bc9d4575..33769ef0 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -35,7 +35,7 @@ import static carpet.settings.RuleCategory.CLIENT; @SuppressWarnings("CanBeFinal") public class CarpetSettings { - public static final String carpetVersion = "1.3.16+v200325"; + public static final String carpetVersion = "1.3.17+v200401"; public static final Logger LOG = LogManager.getLogger(); public static boolean skipGenerationChecks = false; public static boolean impendingFillSkipUpdates = false; diff --git a/src/main/java/carpet/commands/PerimeterInfoCommand.java b/src/main/java/carpet/commands/PerimeterInfoCommand.java index 06760f38..27b80b45 100644 --- a/src/main/java/carpet/commands/PerimeterInfoCommand.java +++ b/src/main/java/carpet/commands/PerimeterInfoCommand.java @@ -7,6 +7,7 @@ import carpet.utils.PerimeterDiagnostics; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import net.minecraft.command.suggestion.SuggestionProviders; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.entity.mob.MobEntity; import net.minecraft.server.command.ServerCommandSource; @@ -51,15 +52,17 @@ public class PerimeterInfoCommand if (mobId != null) { nbttagcompound.putString("id", mobId); - entityliving = (MobEntity) EntityType.loadEntityWithPassengers(nbttagcompound, source.getWorld(), (entity_1x) -> { + Entity baseEntity = EntityType.loadEntityWithPassengers(nbttagcompound, source.getWorld(), (entity_1x) -> { entity_1x.refreshPositionAndAngles(pos.offset(Direction.UP,2), entity_1x.yaw, entity_1x.pitch); return !source.getWorld().tryLoadEntity(entity_1x) ? null : entity_1x; }); - if (entityliving == null) + if (!(baseEntity instanceof MobEntity)) { Messenger.m(source, "r Failed to spawn test entity"); + if (baseEntity != null) baseEntity.remove(); return 0; } + entityliving = (MobEntity) baseEntity; } PerimeterDiagnostics.Result res = PerimeterDiagnostics.countSpots(source.getWorld(), pos, entityliving); diff --git a/src/main/java/carpet/commands/PlayerCommand.java b/src/main/java/carpet/commands/PlayerCommand.java index 4440efb4..0ceba52d 100644 --- a/src/main/java/carpet/commands/PlayerCommand.java +++ b/src/main/java/carpet/commands/PlayerCommand.java @@ -246,12 +246,18 @@ public class PlayerCommand } catch (CommandSyntaxException ignored) {} String playerName = StringArgumentType.getString(context, "player"); + if (playerName.length()>40) + { + Messenger.m(context.getSource(), "rb Player name: "+playerName+" is too long"); + return 0; + } MinecraftServer server = source.getMinecraftServer(); PlayerEntity player = EntityPlayerMPFake.createFake(playerName, server, pos.x, pos.y, pos.z, facing.y, facing.x, dim, mode); if (player == null) { Messenger.m(context.getSource(), "rb Player " + StringArgumentType.getString(context, "player") + " doesn't exist " + "and cannot spawn in online mode. Turn the server offline to spawn non-existing players"); + return 0; } return 1; } diff --git a/src/main/java/carpet/script/value/EntityValue.java b/src/main/java/carpet/script/value/EntityValue.java index 4088478a..3cd5726e 100644 --- a/src/main/java/carpet/script/value/EntityValue.java +++ b/src/main/java/carpet/script/value/EntityValue.java @@ -331,6 +331,15 @@ public class EntityValue extends Value return Value.NULL; }); + put("ping", (e, a) -> { + if (e instanceof ServerPlayerEntity) + { + ServerPlayerEntity spe = (ServerPlayerEntity) e; + return new NumericValue(spe.pingMilliseconds); + } + return Value.NULL; + }); + //spectating_entity // isGlowing put("effect", (e, a) -> diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index b1e29e88..cbd9994c 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,7 +1,7 @@ { "schemaVersion": 1, "id": "carpet", - "version": "1.3.16", + "version": "1.3.17", "name": "Carpet Mod in Fabric", "description": "Carpet made out of fabric",