Jump to content

Opening a player's inventory on another player's screen


Asweez

Recommended Posts

Do you just want to display it? Or interact with it (like take things in and out)?

 

I'm not sure but I think you can make a container that combines any number of inventories. The "glue" that holds a container together is the inventorySlots List. You can make a custom Container that takes in various inventories (like another player's) and then map those to slots in the container. Then they should be available for display, and they should sync between client and server (provided you implement an IGuiHandler as well).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

I dont know if this is going to work, but whe  adding a slot to a container, you can put in an EntityPlayer IInventory Slotindex etc.. What if you pass through the target player and put it in the addslot methode Instead of the player wich opens the container?

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

Do you just want to display it? Or interact with it (like take things in and out)?

 

I'm not sure but I think you can make a container that combines any number of inventories. The "glue" that holds a container together is the inventorySlots List. You can make a custom Container that takes in various inventories (like another player's) and then map those to slots in the container. Then they should be available for display, and they should sync between client and server (provided you implement an IGuiHandler as well).

 

How would I make the game show a container with another players inv slots? And why would I need a GuiHandler?

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Link to comment
Share on other sites

A gui is nothing more than a screen wich displays data you put in. in order to be able to ineract with a gui, you need an regular guiHandler and Gui class. Beside that you need an container wich is linked to your Gui. (The container class containes the data and methodes to update the Gui). So in order to display an other players inventory, you'll need to get the instance of the other player in your container class, and use ot to retrieve data. Thats basicly it. Other than that, its just an regular Gui setup

Projects:

Discontinued:

- N2ConfigAPI

- Meachanical Crafting Table

 

Latest:

- CollectionUtils

 

Coöperations:

- InGameConfigManager

Link to comment
Share on other sites

Okay, you seem a bit confused. Let me try to break it down for you.

 

You want to do something custom, so you're going to have to do some work. Custom GUIs aren't hard, but there are a couple tricky points and it takes a fair bit of coding to get right.

 

If you have a GUI that shows an inventory (I mean it has slots that you can move things into and out from) then it is recommended you use a Container with IGuiHandler. A Container helps map the slots in the GUI to whatever inventory you want, and the IGuiHandler ensures everything gets synced between client and server.

 

The only thing different about your GUI is you want the inventory to be from a different player. Like we've said above, that isn't really that different -- you can simply pass that in like you would the local player's inventory.

 

But the big question is how you find the player. Are you clicking on the other player, or are you just opening this GUI at some other point? If you're clicking on the player, then you can just treat it like an Entity interaction, check that it is EntityPlayer, cast it to EntityPlayer then take the inventory. If you are not clicking on the player, please describe when you want the GUI to open so we can provide suggestions.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Note:

- Server has inventories of loaded players, to load offline inventory you would need to manipulate .dat on your own.

- Client has only constructed EntityPlayers that are in visible range. Client doesn't know shit about players that are out of range, aside from player list (nicks) sent from server. Have in mind that your client won't always be able to get desired EntityPlayer's instance (well, you can go with nicks).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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