本文整理汇总了Java中net.minecraft.scoreboard.Scoreboard.getOrCreateScore方法的典型用法代码示例。如果您正苦于以下问题:Java Scoreboard.getOrCreateScore方法的具体用法?Java Scoreboard.getOrCreateScore怎么用?Java Scoreboard.getOrCreateScore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.scoreboard.Scoreboard
的用法示例。
在下文中一共展示了Scoreboard.getOrCreateScore方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleUpdateScore
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
/**
* Either updates the score with a specified value or removes the score for an objective
*/
public void handleUpdateScore(SPacketUpdateScore packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == SPacketUpdateScore.Action.CHANGE)
{
Score score = scoreboard.getOrCreateScore(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
}
else if (packetIn.getScoreAction() == SPacketUpdateScore.Action.REMOVE)
{
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
}
else if (scoreobjective != null)
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例2: renderEntityName
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void renderEntityName(AbstractClientPlayer entityIn, double x, double y, double z, String name, double distanceSq)
{
if (distanceSq < 100.0D)
{
Scoreboard scoreboard = entityIn.getWorldScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(2);
if (scoreobjective != null)
{
Score score = scoreboard.getOrCreateScore(entityIn.getName(), scoreobjective);
this.renderLivingLabel(entityIn, score.getScorePoints() + " " + scoreobjective.getDisplayName(), x, y, z, 64);
y += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.025F);
}
}
super.renderEntityName(entityIn, x, y, z, name, distanceSq);
}
示例3: resolve
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
public void resolve(ICommandSender sender)
{
MinecraftServer minecraftserver = sender.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
{
Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);
if (scoreboard.entityHasObjective(this.name, scoreobjective))
{
Score score = scoreboard.getOrCreateScore(this.name, scoreobjective);
this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
}
else
{
this.value = "";
}
}
}
示例4: enablePlayerTrigger
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void enablePlayerTrigger(ICommandSender sender, String[] p_184914_2_, int p_184914_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
String s = getPlayerName(server, sender, p_184914_2_[p_184914_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.convertToObjective(p_184914_2_[p_184914_3_], false, server);
if (scoreobjective.getCriteria() != IScoreCriteria.TRIGGER)
{
throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
}
else
{
Score score = scoreboard.getOrCreateScore(s, scoreobjective);
score.setLocked(false);
notifyCommandListener(sender, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
}
}
}
示例5: resolve
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
public void resolve(ICommandSender sender)
{
MinecraftServer minecraftserver = sender.getServer();
if (minecraftserver != null && minecraftserver.isAnvilFileSet() && StringUtils.isNullOrEmpty(this.value))
{
Scoreboard scoreboard = minecraftserver.worldServerForDimension(0).getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(this.objective);
if (scoreboard.entityHasObjective(this.name, scoreobjective))
{
Score score = scoreboard.getOrCreateScore(this.name, scoreobjective);
this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
return;
}
}
this.value = "";
}
示例6: testPlayerScore
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void testPlayerScore(ICommandSender sender, String[] p_184907_2_, int p_184907_3_, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
String s = getEntityName(server, sender, p_184907_2_[p_184907_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.convertToObjective(p_184907_2_[p_184907_3_++], false, server);
if (!scoreboard.entityHasObjective(s, scoreobjective))
{
throw new CommandException("commands.scoreboard.players.test.notFound", new Object[] {scoreobjective.getName(), s});
}
else
{
int i = p_184907_2_[p_184907_3_].equals("*") ? Integer.MIN_VALUE : parseInt(p_184907_2_[p_184907_3_]);
++p_184907_3_;
int j = p_184907_3_ < p_184907_2_.length && !p_184907_2_[p_184907_3_].equals("*") ? parseInt(p_184907_2_[p_184907_3_], i) : Integer.MAX_VALUE;
Score score = scoreboard.getOrCreateScore(s, scoreobjective);
if (score.getScorePoints() >= i && score.getScorePoints() <= j)
{
notifyCommandListener(sender, this, "commands.scoreboard.players.test.success", new Object[] {Integer.valueOf(score.getScorePoints()), Integer.valueOf(i), Integer.valueOf(j)});
}
else
{
throw new CommandException("commands.scoreboard.players.test.failed", new Object[] {Integer.valueOf(score.getScorePoints()), Integer.valueOf(i), Integer.valueOf(j)});
}
}
}
}
示例7: addPlayerScore
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void addPlayerScore(ICommandSender sender, String[] p_184918_2_, int p_184918_3_, MinecraftServer server) throws CommandException
{
String s = p_184918_2_[p_184918_3_ - 1];
int i = p_184918_3_;
String s1 = getEntityName(server, sender, p_184918_2_[p_184918_3_++]);
if (s1.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s1, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.convertToObjective(p_184918_2_[p_184918_3_++], true, server);
int j = "set".equalsIgnoreCase(s) ? parseInt(p_184918_2_[p_184918_3_++]) : parseInt(p_184918_2_[p_184918_3_++], 0);
if (p_184918_2_.length > p_184918_3_)
{
Entity entity = getEntity(server, sender, p_184918_2_[i]);
try
{
NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(buildString(p_184918_2_, p_184918_3_));
NBTTagCompound nbttagcompound1 = entityToNBT(entity);
if (!NBTUtil.areNBTEquals(nbttagcompound, nbttagcompound1, true))
{
throw new CommandException("commands.scoreboard.players.set.tagMismatch", new Object[] {s1});
}
}
catch (NBTException nbtexception)
{
throw new CommandException("commands.scoreboard.players.set.tagError", new Object[] {nbtexception.getMessage()});
}
}
Scoreboard scoreboard = this.getScoreboard(server);
Score score = scoreboard.getOrCreateScore(s1, scoreobjective);
if ("set".equalsIgnoreCase(s))
{
score.setScorePoints(j);
}
else if ("add".equalsIgnoreCase(s))
{
score.increaseScore(j);
}
else
{
score.decreaseScore(j);
}
notifyCommandListener(sender, this, "commands.scoreboard.players.set.success", new Object[] {scoreobjective.getName(), s1, Integer.valueOf(score.getScorePoints())});
}
}