Posted March 5, 20187 yr I am having problems setting the scoreboard objective display slot. I have a simple score called "score" (for testing purposes), and I want to set the slot to be in the sidebar. I created the score through my code using this method: /** * Set the specified score of the entity. Will create score is score does not exist. * * @param world * @param entity * @param objective * @param value */ public static void setScore(World world, Entity entity, String objective, int value) { if (entity instanceof EntityPlayer) { world.getScoreboard().getOrCreateScore(entity.getName(), world.getScoreboard().getObjective(objective)).setScorePoints(value); //world.getScoreboard().broadcastScoreUpdate(entity.getName(), world.getScoreboard().getObjective(objective)); } else { world.getScoreboard().getOrCreateScore(entity.getCachedUniqueIdString(), world.getScoreboard().getObjective(objective)).setScorePoints(value); //world.getScoreboard().broadcastScoreUpdate(entity.getCachedUniqueIdString(), world.getScoreboard().getObjective(objective)); } } When I try to run the command for this, I get the error that the score doesn't exist. When I try to do it from this method: /** * Set the display slot of the score. * * Can be list, sidebar, or belowName. * * @param world * @param slot * @param objective */ public static void setScoreDisplaySlot(World world, String slot, String objective) { Scoreboard scoreboard = world.getScoreboard(); int i = Scoreboard.getObjectiveDisplaySlotNumber(slot); ScoreObjective objectiveToUse = scoreboard.getObjective(objective); scoreboard.setObjectiveInDisplaySlot(i, objectiveToUse); } (I got that method from the CommandScore class) nothing happens. If I try to create the score in the function using this code: if (!scoreboard.getObjectiveNames().contains(objective)) { scoreboard.addScoreObjective(objective, IScoreCriteria.DUMMY); } the code in my statement runs, but I get an error that the score already existed. If the score already existed, then the command would have been able to sense it, and my code to create the objective should not have run. Getting and setting the score seems to work perfectly fine in the code. Edited March 5, 20187 yr by ptolemy2002
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.