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,

My entity extends TamableAnimal that finally extends Mob and I am using handItems and armorItems (both are a List of ItemStacks).
Everything is working, I can put and remove items from these 'inventories', I can render items above entity head at client side, very well.

But now, I don't know how to create a custom gui screen to interact with these inventories. Gui normally requires containers, but I don't have a container here, just list of itemstacks.
Can someone help me a little here?

Tks
†GnR† Slash

†GnR† Slash

can one man truly make a difference?

4 hours ago, GnRSlashSP said:

Gui normally requires containers, but I don't have a container here, just list of itemstacks.

You can use EntityEquipmentInvWrapper to get an item handler wrapping handItems and armorItems, which you can then use to create the slots in a ContainerMenu.

  • Author
On 8/14/2022 at 3:49 AM, vemerion said:

You can use EntityEquipmentInvWrapper to get an item handler wrapping handItems and armorItems, which you can then use to create the slots in a ContainerMenu.

Thank you for this tip. I think I did it right because it is working on single and multiplayer!
This is what I did with inventory:

I put this inside entity constructor:

handsInvWrapper = new EntityHandsInvWrapper(this);

So, I created this inside the Container:

antItemHandler = antEntity.handsInvWrapper;

antItemHandler is a IItemHandler class.

 

thank you again!

Edited by GnRSlashSP
I did it! it is working!

†GnR† Slash

can one man truly make a difference?

  • Author

Another question:

I have these public functions in my custom entity:

1. void setDropItem(boolean value);
2. void setHomePos();

I am implementing this using network messages, but I want to know if messages is the best way or there is another forge functions do deal with these.

From gui:
a. player can use a checkbox to write on item 1
b. player can use a button to activate item 2

I'll send send a message from gui to the server -> my entity, every time player clicks the button or changes the checkbox.
Am I doing it correctly with messages?

Thanks

†GnR† Slash

can one man truly make a difference?

1 hour ago, GnRSlashSP said:

Am I doing it correctly with messages?

Yes, I would say a custom network message is the best way to do this (at least to my knowledge) :)

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.