Posted April 26, 20178 yr Ok so i have a boolean getting true or false from nbt of a player. When i run print on the boolen it clearly shows true or false but when using it in an if statement it doesnt seem to work. This is the part where im using the boolean - NBTTagCompound data = forgeplayer.getEntityData(); data.setTag("AdminUtils", new NBTTagCompound()); NBTTagCompound adminnbt = data.getCompoundTag("AdminUtils"); adminnbt.setTag("WorldWarnings", new NBTTagCompound()); NBTTagCompound worldwarnings = adminnbt.getCompoundTag("WorldWarnings"); Boolean warning = worldwarnings.getBoolean(world); if (playerpresent) { if (!(worldslist.contains(world))) { if (warning) { System.out.print(String.valueOf(warning); } } } Edited April 26, 20178 yr by Bennyboy1695 Friend helped me solve it
April 26, 20178 yr Author 2 minutes ago, diesieben07 said: Why are you using getEntityData? It's ugly to work with NBT directly like that. You should use a capability. Because i just wanted a simple and quick way to store a players true or false on this bit of code. It may be ugly but for my needs it fits. 5 minutes ago, diesieben07 said: Why are you using the boxed Boolean type instead of boolean? I have tried multiple ways of the boolean, still get the issue, this was just the latest way i tried. 6 minutes ago, diesieben07 said: What is this playerpresent variable? In general: show more of your code. The playerpresent just gets whether the player is online. Here's the full part of that, its using some Sponge methods as its part Sponge and part Forge public void onBlockPlace(ChangeBlockEvent.Place event) { if (AdminUtilsSponge.getInstance().getWorldWarningBoolean()) { String world = event.getTargetWorld().getName(); String worldslist = String.join(", ", AdminUtilsSponge.getInstance().getWorldList()); Optional<Player> player = event.getCause().first(Player.class); Boolean playerpresent = player.isPresent(); String name = player.get().getName(); UUID uuid = player.get().getUniqueId(); EntityPlayer forgeplayer = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUUID(uuid); String block = event.getTransactions().get(0).getFinal().getState().getType().getName(); NBTTagCompound data = forgeplayer.getEntityData(); data.setTag("AdminUtils", new NBTTagCompound()); NBTTagCompound adminnbt = data.getCompoundTag("AdminUtils"); adminnbt.setTag("WorldWarnings", new NBTTagCompound()); NBTTagCompound worldwarnings = adminnbt.getCompoundTag("WorldWarnings"); Boolean warning = worldwarnings.getBoolean(world); if (playerpresent) { if (!(worldslist.contains(world))) { if (warning) { System.out.print(String.valueOf(worldwarnings.getBoolean(world))); } } } } }
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.