fixed scoreboard scarpet API

This commit is contained in:
gnembon committed 2023-08-09 00:55:00 +02:00
1 parent c5e1a5a09e
commit 4421967093
1 file changed
+16 -18
@@ -29,6 +29,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.BossEvent;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.scores.DisplaySlot;
import net.minecraft.world.scores.Objective;
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Score;
@@ -225,32 +226,30 @@ public class Scoreboards
}
return new FormattedTextValue(objective.getDisplayName());
}
case "display_slot" -> { /*
case "display_slot" -> {
if (modify)
{
int slotId = Scoreboard.getDisplaySlotByName(setValue.getString());
if (slotId == -1)
DisplaySlot slot = DisplaySlot.CODEC.byName(setValue.getString());
if (slot == null)
{
throw new InternalExpressionException("Unknown scoreboard display slot: " + setValue.getString());
}
if (objective.equals(scoreboard.getDisplayObjective(slotId)))
if (objective.equals(scoreboard.getDisplayObjective(slot)))
{
return Value.FALSE;
}
scoreboard.setDisplayObjective(slotId, objective);
scoreboard.setDisplayObjective(slot, objective);
return Value.TRUE;
}
List<Value> slots = new ArrayList<>();
for (int i = 0; i < 19; i++)
for (DisplaySlot slot : DisplaySlot.values())
{
if (scoreboard.getDisplayObjective(i) == objective)
if (scoreboard.getDisplayObjective(slot) == objective)
{
String slotName = Scoreboard.getDisplaySlotName(i);
slots.add(StringValue.of(slotName));
slots.add(StringValue.of(slot.getSerializedName()));
}
}
return ListValue.wrap(slots); */
return Value.NULL;
return ListValue.wrap(slots);
}
case "render_type" -> {
if (modify)
@@ -270,12 +269,12 @@ public class Scoreboards
});
expression.addContextFunction("scoreboard_display", 2, (c, t, lv) ->
{ /*
{
CarpetContext cc = (CarpetContext) c;
Scoreboard scoreboard = cc.server().getScoreboard();
String location = lv.get(0).getString();
int slot = Scoreboard.getDisplaySlotByName(location);
if (slot < 0)
DisplaySlot slot = DisplaySlot.CODEC.byName(location);
if (slot == null)
{
throw new InternalExpressionException("Invalid objective slot: " + location);
}
@@ -283,17 +282,16 @@ public class Scoreboards
if (target.isNull())
{
scoreboard.setDisplayObjective(slot, null);
return new NumericValue(slot);
return StringValue.of(slot.getSerializedName());
}
String objectiveString = target.getString();
Objective objective = scoreboard.getOrCreateObjective(objectiveString);
Objective objective = scoreboard.getObjective(objectiveString);
if (objective == null)
{
return Value.NULL;
}
scoreboard.setDisplayObjective(slot, objective);
return new NumericValue(slot); */
return Value.NULL;
return StringValue.of(slot.getSerializedName());
});
expression.addContextFunction("team_list", -1, (c, t, lv) ->