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

Hey all,


First time posting. I have a GUI with a container so when i call player.openGui, it tries to go to my GuiHandler and call getClientGuiElement. However, part of my container requires me to get an EntityPlayer with a UUID, and display some specific info about the player. When my findPlayer function ran on the client side while on a dedicated server, the player just returns null and my gui just displays empty. Is there any way to fix that?

 

Here's how I am finding player right now:

public static EntityPlayer findPlayer(UUID uuid) {
   for (WorldServer ws : DimensionManager.getWorlds()) {
      EntityPlayer player = ws.getPlayerEntityByUUID(uuid);
      if (player != null) return player;
   }
   return null;
}
  • Author

Mainly I need to get the player.getRNG to display a random number of info. The info are specific stuff in my mod that checks for stuff like if the player is a witch, if the player has pets, etc. 

 

Here's the container:

public ContainerTarotTable(UUID id) {
   player = Util.findPlayer(id);
   if (player != null) {
      List<Tarot> valid = GameRegistry.findRegistry(Tarot.class).getValuesCollection().stream().filter(f -> f.isCounted(player)).collect(Collectors.toList());
      if (!valid.isEmpty()) {
         while (!valid.isEmpty() && toRead.size() < 4) {
            int i = player.getRNG().nextInt(valid.size());
            toRead.add(valid.get(i));
            valid.remove(i);
         }
      }
   }
}

Edited by Samaritans

5 minutes ago, Samaritans said:

The info are specific stuff in my mod that checks for stuff like if the player is a witch, if the player has pets, etc.

You need to sync the information from the server to the client through the container. Cause the Client won't always know about the player.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

5 minutes ago, Samaritans said:

Yeah that's what I am asking about, I have no idea how to do that. 

Look at the Furnace's container.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author

Im pretty new to modding and I'm still so confused. I guess i need to addListener and detectAndSendChanges? But the container doesnt have an inventory, so there's no changes? I just need a way to have a player opengui on client side while on a dedicated server so that these info are depicted.

 

The player would be holding an item with NBTTag that has a UUID on it. I read that NBT and get the UUID out and find an EntityPlayer with that UUID. 

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.