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

I am just curious as to how one would go about doing this. Would it be as simple as just creating a method that sets a slot number as the Armor slot?

Im not sure exactly what you are asking. Are you saying you want an item in a hotbar slot to act as armor? If so you could use the LivingHurtEvent check if your item is in the slot and apply some damage reduction.

I am the author of Draconic Evolution

  • Author

Im not sure exactly what you are asking. Are you saying you want an item in a hotbar slot to act as armor? If so you could use the LivingHurtEvent check if your item is in the slot and apply some damage reduction.

 

No I mean like designate the hot bar slot to the far right, number 9,  as a armor slot, except you can only put a Item or Armor of a specific type in that slot. An example would be a type being a Ring, so only a Ring Typed Item would be able to be in Hotbar slot 9.

  • Author

It may be possible but i think you would be better off adding your own inventory slot. Maby something like what Baubles dose.

 

Hmm alright, I thought it wouldve just been easier to use an existing one. Thanks for the help though!

Debate here would be "Do I need that 9th slot?". Anyway you can obviously add new armourSlot using those classes:

IEntityExtendedProperties - store data for player and write/read to/from NBT on player load/exit.

IInventory - create inventory for player.

Container - make server-side handler for inventory

Gui - client side display class for your inventory

Events: EntityConstructing (something alike idr) - to init new IEEP.

Packets: To send from server to all clients the slot and ItemStack in given custom inventory.

There are now 2 similar threads on forums on this topic, have look at:

http://www.minecraftforge.net/forum/index.php/topic,26619.msg135680.html#msg135680

 

Or as you suggested use that 9th slot. The code is obviously shorter:

-You don't need apckets to send custom data.

-You don't need IEEP to store custom slots.

-You don't need Gui/Container to display ANYTHING.

 

So howTo:

Use PlayerTickEvent on SERVER side and check player.inventory#indexOfSlot, you will be checking 1st of all for null ItemStack, then for instance, like if(stack instanceof MyCustomRing), then if it's true you can do whatever you want (e.g get some props from item and add them to player (like speed boost)), if it's false you can get the stack and move it to 1st empty OTHER slot or drop ot on ground (if there are non free).

To do other stuff like Hurting (like armour) you can use as suggested before LivingHurtEvent.

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

  • Author

Debate here would be "Do I need that 9th slot?". Anyway you can obviously add new armourSlot using those classes:

IEntityExtendedProperties - store data for player and write/read to/from NBT on player load/exit.

IInventory - create inventory for player.

Container - make server-side handler for inventory

Gui - client side display class for your inventory

Events: EntityConstructing (something alike idr) - to init new IEEP.

Packets: To send from server to all clients the slot and ItemStack in given custom inventory.

There are now 2 similar threads on forums on this topic, have look at:

http://www.minecraftforge.net/forum/index.php/topic,26619.msg135680.html#msg135680

 

Or as you suggested use that 9th slot. The code is obviously shorter:

-You don't need apckets to send custom data.

-You don't need IEEP to store custom slots.

-You don't need Gui/Container to display ANYTHING.

 

So howTo:

Use PlayerTickEvent on SERVER side and check player.inventory#indexOfSlot, you will be checking 1st of all for null ItemStack, then for instance, like if(stack instanceof MyCustomRing), then if it's true you can do whatever you want (e.g get some props from item and add them to player (like speed boost)), if it's false you can get the stack and move it to 1st empty OTHER slot or drop ot on ground (if there are non free).

To do other stuff like Hurting (like armour) you can use as suggested before LivingHurtEvent.

 

Perfect Thank you

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.