generate method
Implementation
@override
Widget generate(Context context) {
final type = subcommand == "initial"
? 'dummy'
: 'minecraft.custom:minecraft.leave_game';
final s = Scoreboard(
score,
type: type,
);
final current = s[Entity.PlayerName('#current')];
final self = s[Entity.Self()];
final t = target ?? Entity.All();
switch (subcommand) {
case "initial":
if (_then_v != null) {
return Execute(
as: t,
If: Condition.not(self >= 0),
children: [
s,
current.add(1),
_then_v!(current),
self >> current,
],
);
}
break;
case "join":
return For.of([
s,
// This will only pass if the player doesn't have the score (the score cannot be below 0), therefore triggering on first join
Execute.as(
t,
children: [
If(
Condition.or([
Condition.not(self >= 0),
self > 0,
]),
then: [
then!,
self >> 0,
],
)
],
)
]);
}
// if subcommand=rejoin or _then_v=null
return Execute.as(
t.copyWith(scores: [self > 0]),
children: [
s,
then!,
self >> 0,
],
);
}