fixed scoreboard scarpet API
This commit is contained in:
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.BossEvent;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.scores.DisplaySlot;
|
||||||
import net.minecraft.world.scores.Objective;
|
import net.minecraft.world.scores.Objective;
|
||||||
import net.minecraft.world.scores.PlayerTeam;
|
import net.minecraft.world.scores.PlayerTeam;
|
||||||
import net.minecraft.world.scores.Score;
|
import net.minecraft.world.scores.Score;
|
||||||
@@ -225,32 +226,30 @@ public class Scoreboards
|
|||||||
}
|
}
|
||||||
return new FormattedTextValue(objective.getDisplayName());
|
return new FormattedTextValue(objective.getDisplayName());
|
||||||
}
|
}
|
||||||
case "display_slot" -> { /*
|
case "display_slot" -> {
|
||||||
if (modify)
|
if (modify)
|
||||||
{
|
{
|
||||||
int slotId = Scoreboard.getDisplaySlotByName(setValue.getString());
|
DisplaySlot slot = DisplaySlot.CODEC.byName(setValue.getString());
|
||||||
if (slotId == -1)
|
if (slot == null)
|
||||||
{
|
{
|
||||||
throw new InternalExpressionException("Unknown scoreboard display slot: " + setValue.getString());
|
throw new InternalExpressionException("Unknown scoreboard display slot: " + setValue.getString());
|
||||||
}
|
}
|
||||||
if (objective.equals(scoreboard.getDisplayObjective(slotId)))
|
if (objective.equals(scoreboard.getDisplayObjective(slot)))
|
||||||
{
|
{
|
||||||
return Value.FALSE;
|
return Value.FALSE;
|
||||||
}
|
}
|
||||||
scoreboard.setDisplayObjective(slotId, objective);
|
scoreboard.setDisplayObjective(slot, objective);
|
||||||
return Value.TRUE;
|
return Value.TRUE;
|
||||||
}
|
}
|
||||||
List<Value> slots = new ArrayList<>();
|
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(slot.getSerializedName()));
|
||||||
slots.add(StringValue.of(slotName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ListValue.wrap(slots); */
|
return ListValue.wrap(slots);
|
||||||
return Value.NULL;
|
|
||||||
}
|
}
|
||||||
case "render_type" -> {
|
case "render_type" -> {
|
||||||
if (modify)
|
if (modify)
|
||||||
@@ -270,12 +269,12 @@ public class Scoreboards
|
|||||||
});
|
});
|
||||||
|
|
||||||
expression.addContextFunction("scoreboard_display", 2, (c, t, lv) ->
|
expression.addContextFunction("scoreboard_display", 2, (c, t, lv) ->
|
||||||
{ /*
|
{
|
||||||
CarpetContext cc = (CarpetContext) c;
|
CarpetContext cc = (CarpetContext) c;
|
||||||
Scoreboard scoreboard = cc.server().getScoreboard();
|
Scoreboard scoreboard = cc.server().getScoreboard();
|
||||||
String location = lv.get(0).getString();
|
String location = lv.get(0).getString();
|
||||||
int slot = Scoreboard.getDisplaySlotByName(location);
|
DisplaySlot slot = DisplaySlot.CODEC.byName(location);
|
||||||
if (slot < 0)
|
if (slot == null)
|
||||||
{
|
{
|
||||||
throw new InternalExpressionException("Invalid objective slot: " + location);
|
throw new InternalExpressionException("Invalid objective slot: " + location);
|
||||||
}
|
}
|
||||||
@@ -283,17 +282,16 @@ public class Scoreboards
|
|||||||
if (target.isNull())
|
if (target.isNull())
|
||||||
{
|
{
|
||||||
scoreboard.setDisplayObjective(slot, null);
|
scoreboard.setDisplayObjective(slot, null);
|
||||||
return new NumericValue(slot);
|
return StringValue.of(slot.getSerializedName());
|
||||||
}
|
}
|
||||||
String objectiveString = target.getString();
|
String objectiveString = target.getString();
|
||||||
Objective objective = scoreboard.getOrCreateObjective(objectiveString);
|
Objective objective = scoreboard.getObjective(objectiveString);
|
||||||
if (objective == null)
|
if (objective == null)
|
||||||
{
|
{
|
||||||
return Value.NULL;
|
return Value.NULL;
|
||||||
}
|
}
|
||||||
scoreboard.setDisplayObjective(slot, objective);
|
scoreboard.setDisplayObjective(slot, objective);
|
||||||
return new NumericValue(slot); */
|
return StringValue.of(slot.getSerializedName());
|
||||||
return Value.NULL;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expression.addContextFunction("team_list", -1, (c, t, lv) ->
|
expression.addContextFunction("team_list", -1, (c, t, lv) ->
|
||||||
|
|||||||
Reference in new issue
Block a user