scoreboard /1
This commit is contained in:
1 parent
153b04ed1c
commit
90add8bd63
2 files changed
+54
No files matched your search
@@ -76,6 +76,9 @@ import net.minecraft.nbt.StringTag;
|
|||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
import net.minecraft.predicate.entity.EntityPredicates;
|
import net.minecraft.predicate.entity.EntityPredicates;
|
||||||
|
import net.minecraft.scoreboard.Scoreboard;
|
||||||
|
import net.minecraft.scoreboard.ScoreboardObjective;
|
||||||
|
import net.minecraft.scoreboard.ScoreboardPlayerScore;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
@@ -1257,6 +1260,52 @@ public class CarpetExpression
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Scoreboard()
|
||||||
|
{
|
||||||
|
// scoreboard(player,'objective')
|
||||||
|
// scoreboard(player, objective, newValue)
|
||||||
|
this.expr.addLazyFunction("scoreboard", -1, (c, t, lv) ->
|
||||||
|
{
|
||||||
|
CarpetContext cc = (CarpetContext)c;
|
||||||
|
Scoreboard scoreboard = cc.s.getMinecraftServer().getScoreboard();
|
||||||
|
String key;
|
||||||
|
String target = lv.get(0).evalValue(c).getString();
|
||||||
|
Value keyValue = lv.get(1).evalValue(c);
|
||||||
|
if (keyValue instanceof EntityValue)
|
||||||
|
{
|
||||||
|
Entity e = ((EntityValue) keyValue).getEntity();
|
||||||
|
if (e instanceof PlayerEntity)
|
||||||
|
{
|
||||||
|
key = e.getDisplayName().getString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key = e.getUuidAsString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
key = keyValue.getString();
|
||||||
|
}
|
||||||
|
ScoreboardObjective objective = scoreboard.getObjective(target);
|
||||||
|
if (objective == null)
|
||||||
|
return LazyValue.NULL;
|
||||||
|
if (!scoreboard.playerHasObjective(key, objective) && lv.size()==2)
|
||||||
|
return LazyValue.NULL;
|
||||||
|
ScoreboardPlayerScore scoreboardPlayerScore = scoreboard.getPlayerScore(key, objective);
|
||||||
|
Value retval = new NumericValue(scoreboardPlayerScore.getScore());
|
||||||
|
if (lv.size() > 2)
|
||||||
|
{
|
||||||
|
scoreboardPlayerScore.setScore(NumericValue.asNumber(lv.get(2).evalValue(c)).getInt());
|
||||||
|
}
|
||||||
|
return (_c, _t) -> retval;
|
||||||
|
});
|
||||||
|
|
||||||
|
//"objective_remove", "objective_add", "objective_keys", "set_display"
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void API_InventoryManipulation()
|
public void API_InventoryManipulation()
|
||||||
{
|
{
|
||||||
this.expr.addLazyFunction("stack_limit", 1, (c, t, lv) ->
|
this.expr.addLazyFunction("stack_limit", 1, (c, t, lv) ->
|
||||||
@@ -2741,6 +2790,7 @@ public class CarpetExpression
|
|||||||
API_InventoryManipulation();
|
API_InventoryManipulation();
|
||||||
API_IteratingOverAreasOfBlocks();
|
API_IteratingOverAreasOfBlocks();
|
||||||
API_AuxiliaryAspects();
|
API_AuxiliaryAspects();
|
||||||
|
Scoreboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean fillAndScanCommand(ScriptHost host, int x, int y, int z)
|
public boolean fillAndScanCommand(ScriptHost host, int x, int y, int z)
|
||||||
|
|||||||
@@ -189,4 +189,8 @@ public class NumericValue extends Value
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getInt()
|
||||||
|
{
|
||||||
|
return (int)getLong();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user