remove markers when app unloads or not loaded
This commit is contained in:
1 parent
b90da71359
commit
e21cbf5f59
8 files changed
+76
-4
No files matched your search
@@ -2737,7 +2737,8 @@ public class CarpetExpression
|
||||
(float)pointLocator.yaw,
|
||||
(float) pointLocator.pitch
|
||||
);
|
||||
armorstand.addScoreboardTag("__scarpet_marker");
|
||||
armorstand.addScoreboardTag(ExpressionInspector.MARKER_STRING+"_"+((cc.host.getName()==null)?"":cc.host.getName()));
|
||||
armorstand.addScoreboardTag(ExpressionInspector.MARKER_STRING);
|
||||
if (targetBlock != null)
|
||||
armorstand.setEquippedStack(EquipmentSlot.HEAD, new ItemStack(targetBlock.getBlock().asItem()));
|
||||
if (!name.isEmpty())
|
||||
@@ -2757,7 +2758,8 @@ public class CarpetExpression
|
||||
this.expr.addLazyFunction("remove_all_markers", 0, (c, t, lv) -> {
|
||||
CarpetContext cc = (CarpetContext)c;
|
||||
int total = 0;
|
||||
for (Entity e : cc.s.getWorld().getEntities(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains("__scarpet_marker")))
|
||||
String markerName = ExpressionInspector.MARKER_STRING+"_"+((cc.host.getName()==null)?"":cc.host.getName());
|
||||
for (Entity e : cc.s.getWorld().getEntities(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains(markerName)))
|
||||
{
|
||||
total ++;
|
||||
e.remove();
|
||||
|
||||
@@ -358,6 +358,7 @@ public class CarpetScriptServer
|
||||
}
|
||||
// stop all events associated with name
|
||||
events.removeAllHostEvents(name);
|
||||
modules.get(name).onClose();
|
||||
modules.remove(name);
|
||||
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
|
||||
Messenger.m(source, "gi Removed "+name+" app");
|
||||
|
||||
@@ -2824,6 +2824,8 @@ public class Expression implements Cloneable
|
||||
|
||||
addUnaryFunction("title", v -> new StringValue(WordUtils.capitalizeFully(v.getString())));
|
||||
|
||||
// TODO: split, replace, replace_first, escape_special (to make nbt to string)
|
||||
|
||||
|
||||
addUnaryFunction("type", v -> new StringValue(v.getTypeString()));
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class ExpressionInspector
|
||||
{
|
||||
public static final String MARKER_STRING = "__scarpet_marker";
|
||||
public static List<String> Expression_getExpressionSnippet(Tokenizer.Token token, Expression expr)
|
||||
{
|
||||
return Expression.getExpressionSnippet(token, expr);
|
||||
|
||||
@@ -9,9 +9,12 @@ import carpet.script.value.NumericValue;
|
||||
import carpet.script.value.StringValue;
|
||||
import carpet.script.value.Value;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.math.BigInteger;
|
||||
@@ -288,6 +291,14 @@ public class ScriptHost
|
||||
{
|
||||
if (this.saveTimeout > 0)
|
||||
dumpState();
|
||||
String markerName = ExpressionInspector.MARKER_STRING+"_"+((getName()==null)?"":getName());
|
||||
for (ServerWorld world : CarpetServer.minecraft_server.getWorlds())
|
||||
{
|
||||
for (Entity e : world.getEntities(EntityType.ARMOR_STAND, (as) -> as.getScoreboardTags().contains(markerName)))
|
||||
{
|
||||
e.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPerPlayer(boolean isPerUser)
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.client.network.packet.EntityPassengersSetS2CPacket;
|
||||
import net.minecraft.client.network.packet.EntityPositionS2CPacket;
|
||||
import net.minecraft.command.EntitySelector;
|
||||
import net.minecraft.command.EntitySelectorReader;
|
||||
import net.minecraft.command.arguments.NbtPathArgumentType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityPose;
|
||||
import net.minecraft.entity.EntityType;
|
||||
@@ -28,7 +27,6 @@ import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.entity.mob.MobEntityWithAi;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
@@ -423,6 +421,7 @@ public class EntityValue extends Value
|
||||
private static void updatePosition(Entity e)
|
||||
{
|
||||
if (e instanceof ServerPlayerEntity)
|
||||
// TODO next - figure out proper way of informting client about pos changes
|
||||
((ServerPlayerEntity)e).networkHandler.requestTeleport(e.x, e.y, e.z, e.yaw, e.pitch);
|
||||
else
|
||||
((ServerWorld)e.getEntityWorld()).method_14178().sendToNearbyPlayers(e,new EntityPositionS2CPacket(e));
|
||||
|
||||
Reference in new issue
Block a user