Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by Bennyboy1695
Friend helped me solve it

  • 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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.