本文整理汇总了Java中net.minecraft.scoreboard.Scoreboard.getObjective方法的典型用法代码示例。如果您正苦于以下问题:Java Scoreboard.getObjective方法的具体用法?Java Scoreboard.getObjective怎么用?Java Scoreboard.getObjective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.scoreboard.Scoreboard
的用法示例。
在下文中一共展示了Scoreboard.getObjective方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: convertToObjective
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected ScoreObjective convertToObjective(String name, boolean forWrite, MinecraftServer server) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard(server);
ScoreObjective scoreobjective = scoreboard.getObjective(name);
if (scoreobjective == null)
{
throw new CommandException("commands.scoreboard.objectiveNotFound", new Object[] {name});
}
else if (forWrite && scoreobjective.getCriteria().isReadOnly())
{
throw new CommandException("commands.scoreboard.objectiveReadOnly", new Object[] {name});
}
else
{
return scoreobjective;
}
}
示例3: handleDisplayObjective
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
/**
* Removes or sets the ScoreObjective to be displayed at a particular scoreboard position (list, sidebar, below
* name)
*/
public void handleDisplayObjective(SPacketDisplayObjective packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
if (packetIn.getName().isEmpty())
{
scoreboard.setObjectiveInDisplaySlot(packetIn.getPosition(), (ScoreObjective)null);
}
else
{
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.getName());
scoreboard.setObjectiveInDisplaySlot(packetIn.getPosition(), scoreobjective);
}
}
示例4: handleDisplayScoreboard
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
/**
* Removes or sets the ScoreObjective to be displayed at a particular scoreboard position (list, sidebar, below
* name)
*/
public void handleDisplayScoreboard(S3DPacketDisplayScoreboard packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
if (packetIn.func_149370_d().length() == 0)
{
scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), (ScoreObjective)null);
}
else
{
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.func_149370_d());
scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), scoreobjective);
}
}
示例5: 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;
}
示例6: 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);
}
}
}
示例7: 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);
}
}
}
示例8: handleDisplayScoreboard
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
/**
* Removes or sets the ScoreObjective to be displayed at a particular scoreboard
* position (list, sidebar, below name)
*/
public void handleDisplayScoreboard(S3DPacketDisplayScoreboard packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
if (packetIn.func_149370_d().length() == 0) {
scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), (ScoreObjective) null);
} else {
ScoreObjective scoreobjective = scoreboard.getObjective(packetIn.func_149370_d());
scoreboard.setObjectiveInDisplaySlot(packetIn.func_149371_c(), scoreobjective);
}
}
示例9: handleScoreboardObjective
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
/**
* May create a scoreboard objective, remove an objective from the scoreboard or update an objectives' displayname
*/
public void handleScoreboardObjective(S3BPacketScoreboardObjective packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
if (packetIn.func_149338_e() == 0)
{
ScoreObjective scoreobjective = scoreboard.addScoreObjective(packetIn.func_149339_c(), IScoreObjectiveCriteria.DUMMY);
scoreobjective.setDisplayName(packetIn.func_149337_d());
scoreobjective.setRenderType(packetIn.func_179817_d());
}
else
{
ScoreObjective scoreobjective1 = scoreboard.getObjective(packetIn.func_149339_c());
if (packetIn.func_149338_e() == 1)
{
scoreboard.removeObjective(scoreobjective1);
}
else if (packetIn.func_149338_e() == 2)
{
scoreobjective1.setDisplayName(packetIn.func_149337_d());
scoreobjective1.setRenderType(packetIn.func_179817_d());
}
}
}
示例10: handleScoreboardObjective
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
/**
* May create a scoreboard objective, remove an objective from the scoreboard or update an objectives' displayname
*/
public void handleScoreboardObjective(SPacketScoreboardObjective packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
Scoreboard scoreboard = this.clientWorldController.getScoreboard();
if (packetIn.getAction() == 0)
{
ScoreObjective scoreobjective = scoreboard.addScoreObjective(packetIn.getObjectiveName(), IScoreCriteria.DUMMY);
scoreobjective.setDisplayName(packetIn.getObjectiveValue());
scoreobjective.setRenderType(packetIn.getRenderType());
}
else
{
ScoreObjective scoreobjective1 = scoreboard.getObjective(packetIn.getObjectiveName());
if (packetIn.getAction() == 1)
{
scoreboard.removeObjective(scoreobjective1);
}
else if (packetIn.getAction() == 2)
{
scoreobjective1.setDisplayName(packetIn.getObjectiveValue());
scoreobjective1.setRenderType(packetIn.getRenderType());
}
}
}
示例11: 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_);
}
}
}
}
}
示例12: addObjective
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void addObjective(ICommandSender sender, String[] args, int index) throws CommandException
{
String s = args[index++];
String s1 = args[index++];
Scoreboard scoreboard = this.getScoreboard();
IScoreObjectiveCriteria iscoreobjectivecriteria = (IScoreObjectiveCriteria)IScoreObjectiveCriteria.INSTANCES.get(s1);
if (iscoreobjectivecriteria == null)
{
throw new WrongUsageException("commands.scoreboard.objectives.add.wrongType", new Object[] {s1});
}
else if (scoreboard.getObjective(s) != null)
{
throw new CommandException("commands.scoreboard.objectives.add.alreadyExists", new Object[] {s});
}
else if (s.length() > 16)
{
throw new SyntaxErrorException("commands.scoreboard.objectives.add.tooLong", new Object[] {s, Integer.valueOf(16)});
}
else if (s.length() == 0)
{
throw new WrongUsageException("commands.scoreboard.objectives.add.usage", new Object[0]);
}
else
{
if (args.length > index)
{
String s2 = getChatComponentFromNthArg(sender, args, index).getUnformattedText();
if (s2.length() > 32)
{
throw new SyntaxErrorException("commands.scoreboard.objectives.add.displayTooLong", new Object[] {s2, Integer.valueOf(32)});
}
if (s2.length() > 0)
{
scoreboard.addScoreObjective(s, iscoreobjectivecriteria).setDisplayName(s2);
}
else
{
scoreboard.addScoreObjective(s, iscoreobjectivecriteria);
}
}
else
{
scoreboard.addScoreObjective(s, iscoreobjectivecriteria);
}
notifyOperators(sender, this, "commands.scoreboard.objectives.add.success", new Object[] {s});
}
}
示例13: addObjective
import net.minecraft.scoreboard.Scoreboard; //导入方法依赖的package包/类
protected void addObjective(ICommandSender sender, String[] commandArgs, int argStartIndex, MinecraftServer server) throws CommandException
{
String s = commandArgs[argStartIndex++];
String s1 = commandArgs[argStartIndex++];
Scoreboard scoreboard = this.getScoreboard(server);
IScoreCriteria iscorecriteria = (IScoreCriteria)IScoreCriteria.INSTANCES.get(s1);
if (iscorecriteria == null)
{
throw new WrongUsageException("commands.scoreboard.objectives.add.wrongType", new Object[] {s1});
}
else if (scoreboard.getObjective(s) != null)
{
throw new CommandException("commands.scoreboard.objectives.add.alreadyExists", new Object[] {s});
}
else if (s.length() > 16)
{
throw new SyntaxErrorException("commands.scoreboard.objectives.add.tooLong", new Object[] {s, Integer.valueOf(16)});
}
else if (s.isEmpty())
{
throw new WrongUsageException("commands.scoreboard.objectives.add.usage", new Object[0]);
}
else
{
if (commandArgs.length > argStartIndex)
{
String s2 = getChatComponentFromNthArg(sender, commandArgs, argStartIndex).getUnformattedText();
if (s2.length() > 32)
{
throw new SyntaxErrorException("commands.scoreboard.objectives.add.displayTooLong", new Object[] {s2, Integer.valueOf(32)});
}
if (s2.isEmpty())
{
scoreboard.addScoreObjective(s, iscorecriteria);
}
else
{
scoreboard.addScoreObjective(s, iscorecriteria).setDisplayName(s2);
}
}
else
{
scoreboard.addScoreObjective(s, iscorecriteria);
}
notifyCommandListener(sender, this, "commands.scoreboard.objectives.add.success", new Object[] {s});
}
}