Jump to content

Designating HotBar slot as CustomArmor slot


jewell012

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.

Announcements



×
×
  • Create New...

Important Information

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