23w46a
This commit is contained in:
1 parent
687591c5d5
commit
df017bb122
4 files changed
+35
-32
No files matched your search
+2
-2
@@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check https://fabricmc.net/develop/
|
||||
minecraft_version=23w45a
|
||||
minecraft_version=23w46a
|
||||
loader_version=0.14.24
|
||||
jsr305_version=3.0.2
|
||||
fabric_version=0.90.8+1.20.3
|
||||
fabric_version=0.90.9+1.20.3
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.4.125
|
||||
|
||||
@@ -27,26 +27,22 @@ import net.minecraft.server.bossevents.CustomBossEvent;
|
||||
import net.minecraft.server.bossevents.CustomBossEvents;
|
||||
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;
|
||||
import net.minecraft.world.scores.ScoreAccess;
|
||||
import net.minecraft.world.scores.ScoreHolder;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.Team;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
|
||||
public class Scoreboards
|
||||
{
|
||||
private static String getScoreboardKeyFromValue(Value keyValue)
|
||||
private static ScoreHolder getScoreboardKeyFromValue(Value keyValue)
|
||||
{
|
||||
if (keyValue instanceof final EntityValue ev)
|
||||
{
|
||||
Entity e = ev.getEntity();
|
||||
return e instanceof Player ? e.getName().getString() : e.getStringUUID();
|
||||
}
|
||||
return keyValue.getString();
|
||||
return keyValue instanceof EntityValue ev
|
||||
? ev.getEntity()
|
||||
: ScoreHolder.forNameOnly(keyValue.getString());
|
||||
}
|
||||
|
||||
public static void apply(Expression expression)
|
||||
@@ -69,28 +65,29 @@ public class Scoreboards
|
||||
}
|
||||
if (lv.size() == 1)
|
||||
{
|
||||
return ListValue.wrap(scoreboard.getPlayerScores(objective).stream().map(s -> new StringValue(s.getOwner())));
|
||||
return ListValue.wrap(scoreboard.listPlayerScores(objective).stream().map(s -> new StringValue(s.owner())));
|
||||
}
|
||||
String key = getScoreboardKeyFromValue(lv.get(1));
|
||||
ScoreHolder key = getScoreboardKeyFromValue(lv.get(1));
|
||||
if (lv.size() == 2)
|
||||
{
|
||||
return !scoreboard.hasPlayerScore(key, objective)
|
||||
return scoreboard.getPlayerScoreInfo(key, objective) == null
|
||||
? Value.NULL
|
||||
: NumericValue.of(scoreboard.getOrCreatePlayerScore(key, objective).getScore());
|
||||
: NumericValue.of(scoreboard.getOrCreatePlayerScore(key, objective).get());
|
||||
}
|
||||
|
||||
Value value = lv.get(2);
|
||||
if (value.isNull())
|
||||
{
|
||||
Score score = scoreboard.getOrCreatePlayerScore(key, objective);
|
||||
scoreboard.resetPlayerScore(key, objective);
|
||||
return NumericValue.of(score.getScore());
|
||||
int score = scoreboard.getOrCreatePlayerScore(key, objective).get();
|
||||
scoreboard.resetSinglePlayerScore(key, objective);
|
||||
return NumericValue.of(score);
|
||||
}
|
||||
if (value instanceof NumericValue)
|
||||
{
|
||||
Score score = scoreboard.getOrCreatePlayerScore(key, objective);
|
||||
score.setScore(NumericValue.asNumber(value).getInt());
|
||||
return NumericValue.of(score.getScore());
|
||||
ScoreAccess score = scoreboard.getOrCreatePlayerScore(key, objective);
|
||||
int previous = score.get();
|
||||
score.set(NumericValue.asNumber(value).getInt());
|
||||
return NumericValue.of(previous);
|
||||
}
|
||||
throw new InternalExpressionException("'scoreboard' requires a number or null as the third parameter");
|
||||
});
|
||||
@@ -114,14 +111,14 @@ public class Scoreboards
|
||||
scoreboard.removeObjective(objective);
|
||||
return Value.TRUE;
|
||||
}
|
||||
String key = getScoreboardKeyFromValue(lv.get(1));
|
||||
if (!scoreboard.hasPlayerScore(key, objective))
|
||||
ScoreHolder key = getScoreboardKeyFromValue(lv.get(1));
|
||||
if (scoreboard.getPlayerScoreInfo(key, objective) == null)
|
||||
{
|
||||
return Value.NULL;
|
||||
}
|
||||
Score scoreboardPlayerScore = scoreboard.getOrCreatePlayerScore(key, objective);
|
||||
Value previous = new NumericValue(scoreboardPlayerScore.getScore());
|
||||
scoreboard.resetPlayerScore(key, objective);
|
||||
ScoreAccess scoreboardPlayerScore = scoreboard.getOrCreatePlayerScore(key, objective);
|
||||
Value previous = new NumericValue(scoreboardPlayerScore.get());
|
||||
scoreboard.resetSinglePlayerScore(key, objective);
|
||||
return previous;
|
||||
});
|
||||
|
||||
@@ -170,7 +167,7 @@ public class Scoreboards
|
||||
scoreboard.onObjectiveAdded(objective);
|
||||
return Value.FALSE;
|
||||
}
|
||||
scoreboard.addObjective(objectiveName, criterion, Component.literal(objectiveName), criterion.getDefaultRenderType());
|
||||
scoreboard.addObjective(objectiveName, criterion, Component.literal(objectiveName), criterion.getDefaultRenderType(), false, null);
|
||||
return Value.TRUE;
|
||||
});
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.storage.loot.LootDataType;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.ScoreHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -778,10 +778,10 @@ public abstract class CommandArgument
|
||||
@Override
|
||||
protected Value getValueFromContext(CommandContext<CommandSourceStack> context, String param) throws CommandSyntaxException
|
||||
{
|
||||
Collection<String> holders = ScoreHolderArgument.getNames(context, param);
|
||||
Collection<ScoreHolder> holders = ScoreHolderArgument.getNames(context, param);
|
||||
if (!single)
|
||||
{
|
||||
return ListValue.wrap(holders.stream().map(StringValue::of));
|
||||
return ListValue.wrap(holders.stream().map(ValueConversions::of));
|
||||
}
|
||||
int size = holders.size();
|
||||
if (size == 0)
|
||||
@@ -790,7 +790,7 @@ public abstract class CommandArgument
|
||||
}
|
||||
if (size == 1)
|
||||
{
|
||||
return StringValue.of(holders.iterator().next());
|
||||
return ValueConversions.of(holders.iterator().next());
|
||||
}
|
||||
throw new SimpleCommandExceptionType(Component.literal("Multiple score holders returned while only one was requested" + " for custom type " + suffix)).create();
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.ScoreHolder;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -384,6 +385,11 @@ public class ValueConversions
|
||||
return MapValue.wrap(ret);
|
||||
}
|
||||
|
||||
public static Value of(final ScoreHolder scoreHolder)
|
||||
{
|
||||
return FormattedTextValue.of(scoreHolder.getFeedbackDisplayName());
|
||||
}
|
||||
|
||||
public static Value fromProperty(BlockState state, Property<?> p)
|
||||
{
|
||||
Comparable<?> object = state.getValue(p);
|
||||
|
||||
Reference in new issue
Block a user