本文整理汇总了Java中net.minecraft.scoreboard.Scoreboard.getValueFromObjective方法的典型用法代码示例。如果您正苦于以下问题:Java Scoreboard.getValueFromObjective方法的具体用法?Java Scoreboard.getValueFromObjective怎么用?Java Scoreboard.getValueFromObjective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.scoreboard.Scoreboard
的用法示例。
在下文中一共展示了Scoreboard.getValueFromObjective方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnformattedTextForChat
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
/**
* Gets the text of this component, without any special formatting codes added, for chat. TODO: why is this two
* different methods?
*/
public String getUnformattedTextForChat()
{
MinecraftServer minecraftserver = MinecraftServer.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.getValueFromObjective(this.name, scoreobjective);
this.setValue(String.format("%d", new Object[] {Integer.valueOf(score.getScorePoints())}));
}
else
{
this.value = "";
}
}
return this.value;
}
示例2: func_175779_n
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void func_175779_n(ICommandSender p_175779_1_, String[] p_175779_2_, int p_175779_3_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
String s = getPlayerName(p_175779_1_, p_175779_2_[p_175779_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.getObjective(p_175779_2_[p_175779_3_], false);
if (scoreobjective.getCriteria() != IScoreObjectiveCriteria.TRIGGER)
{
throw new CommandException("commands.scoreboard.players.enable.noTrigger", new Object[] {scoreobjective.getName()});
}
else
{
Score score = scoreboard.getValueFromObjective(s, scoreobjective);
score.setLocked(false);
notifyOperators(p_175779_1_, this, "commands.scoreboard.players.enable.success", new Object[] {scoreobjective.getName(), s});
}
}
}
示例3: 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(S3CPacketUpdateScore packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE)
{
Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
}
else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE)
{
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName()))
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective)null);
}
else if (scoreobjective != null)
{
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例4: renderOffsetLivingLabel
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void renderOffsetLivingLabel(AbstractClientPlayer entityIn, double x, double y, double z, String str, float p_177069_9_, double p_177069_10_)
{
if (p_177069_10_ < 100.0D)
{
Scoreboard scoreboard = entityIn.getWorldScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(2);
if (scoreobjective != null)
{
Score score = scoreboard.getValueFromObjective(entityIn.getName(), scoreobjective);
this.renderLivingLabel(entityIn, score.getScorePoints() + " " + scoreobjective.getDisplayName(), x, y, z, 64);
y += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * p_177069_9_);
}
}
super.renderOffsetLivingLabel(entityIn, x, y, z, str, p_177069_9_, p_177069_10_);
}
示例5: 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(S3CPacketUpdateScore packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.CHANGE) {
Score score = scoreboard.getValueFromObjective(packetIn.getPlayerName(), scoreobjective);
score.setScorePoints(packetIn.getScoreValue());
} else if (packetIn.getScoreAction() == S3CPacketUpdateScore.Action.REMOVE) {
if (StringUtils.isNullOrEmpty(packetIn.getObjectiveName())) {
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), (ScoreObjective) null);
} else if (scoreobjective != null) {
scoreboard.removeObjectiveFromEntity(packetIn.getPlayerName(), scoreobjective);
}
}
}
示例6: func_175781_o
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void func_175781_o(ICommandSender p_175781_1_, String[] p_175781_2_, int p_175781_3_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
String s = getEntityName(p_175781_1_, p_175781_2_[p_175781_3_++]);
if (s.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.getObjective(p_175781_2_[p_175781_3_++], false);
if (!scoreboard.entityHasObjective(s, scoreobjective))
{
throw new CommandException("commands.scoreboard.players.test.notFound", new Object[] {scoreobjective.getName(), s});
}
else
{
int i = p_175781_2_[p_175781_3_].equals("*") ? Integer.MIN_VALUE : parseInt(p_175781_2_[p_175781_3_]);
++p_175781_3_;
int j = p_175781_3_ < p_175781_2_.length && !p_175781_2_[p_175781_3_].equals("*") ? parseInt(p_175781_2_[p_175781_3_], i) : Integer.MAX_VALUE;
Score score = scoreboard.getValueFromObjective(s, scoreobjective);
if (score.getScorePoints() >= i && score.getScorePoints() <= j)
{
notifyOperators(p_175781_1_, 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: func_179672_a
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
public void func_179672_a(final ICommandSender sender, CommandResultStats.Type resultTypeIn, int p_179672_3_)
{
String s = this.field_179675_c[resultTypeIn.getTypeID()];
if (s != null)
{
ICommandSender icommandsender = new ICommandSender()
{
public String getName()
{
return sender.getName();
}
public IChatComponent getDisplayName()
{
return sender.getDisplayName();
}
public void addChatMessage(IChatComponent component)
{
sender.addChatMessage(component);
}
public boolean canCommandSenderUseCommand(int permLevel, String commandName)
{
return true;
}
public BlockPos getPosition()
{
return sender.getPosition();
}
public Vec3 getPositionVector()
{
return sender.getPositionVector();
}
public World getEntityWorld()
{
return sender.getEntityWorld();
}
public Entity getCommandSenderEntity()
{
return sender.getCommandSenderEntity();
}
public boolean sendCommandFeedback()
{
return sender.sendCommandFeedback();
}
public void setCommandStat(CommandResultStats.Type type, int amount)
{
sender.setCommandStat(type, amount);
}
};
String s1;
try
{
s1 = CommandBase.getEntityName(icommandsender, s);
}
catch (EntityNotFoundException var11)
{
return;
}
String s2 = this.field_179673_d[resultTypeIn.getTypeID()];
if (s2 != null)
{
Scoreboard scoreboard = sender.getEntityWorld().getScoreboard();
ScoreObjective scoreobjective = scoreboard.getObjective(s2);
if (scoreobjective != null)
{
if (scoreboard.entityHasObjective(s1, scoreobjective))
{
Score score = scoreboard.getValueFromObjective(s1, scoreobjective);
score.setScorePoints(p_179672_3_);
}
}
}
}
}
示例8: setPlayer
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void setPlayer(ICommandSender p_147197_1_, String[] p_147197_2_, int p_147197_3_) throws CommandException
{
String s = p_147197_2_[p_147197_3_ - 1];
int i = p_147197_3_;
String s1 = getEntityName(p_147197_1_, p_147197_2_[p_147197_3_++]);
if (s1.length() > 40)
{
throw new SyntaxErrorException("commands.scoreboard.players.name.tooLong", new Object[] {s1, Integer.valueOf(40)});
}
else
{
ScoreObjective scoreobjective = this.getObjective(p_147197_2_[p_147197_3_++], true);
int j = s.equalsIgnoreCase("set") ? parseInt(p_147197_2_[p_147197_3_++]) : parseInt(p_147197_2_[p_147197_3_++], 0);
if (p_147197_2_.length > p_147197_3_)
{
Entity entity = func_175768_b(p_147197_1_, p_147197_2_[i]);
try
{
NBTTagCompound nbttagcompound = JsonToNBT.getTagFromJson(buildString(p_147197_2_, p_147197_3_));
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
entity.writeToNBT(nbttagcompound1);
if (!NBTUtil.func_181123_a(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();
Score score = scoreboard.getValueFromObjective(s1, scoreobjective);
if (s.equalsIgnoreCase("set"))
{
score.setScorePoints(j);
}
else if (s.equalsIgnoreCase("add"))
{
score.increseScore(j);
}
else
{
score.decreaseScore(j);
}
notifyOperators(p_147197_1_, this, "commands.scoreboard.players.set.success", new Object[] {scoreobjective.getName(), s1, Integer.valueOf(score.getScorePoints())});
}
}