Jump to content

Create an item and give it lore?


robertx555

Recommended Posts

Hello, new to forge modding, i did this with bukkit modding so i'll explain

 

With bukkit, i created an item say a diamond sword, i made it roll random stats and then set the lore with setitemmeta() and setlore()

 

how do i set the lores with forge?

 

https://i.imgur.com/HYysu.png

 

here pic in case you're confused what i mean by lore

 

Thanks!

 

Link to comment
Share on other sites

Are you...

Adding lore to your own item?

Or...

Adding lore to a vanilla item?

 

How you do this depends on the answer.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

7 minutes ago, Draco18s said:

Are you...

Adding lore to your own item?

Or...

Adding lore to a vanilla item?

 

How you do this depends on the answer.

i want to use vanilla items, a wooden sword for example, and be able to create infinite amounts of different items by changing the sword's lore. 

 

like

wooden sword: critical chance 5%

wooden sword: critical damage 20%

Edited by robertx555
Link to comment
Share on other sites

Lore doesn't actually make the item any different. It's just text displayed in a tooltip.

You can modify the text displayed by subscribing to the ItemTooltipEvent, but adding "Crit chance: 5%"  won't actually make the item have a 5% crit chance.

For actual effects, some of them can be handled via AttributeModifiers which can be applied via NBT tags on item stacks. But this is a very limited set of effects (namely, attack damage and attack speed).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

20 minutes ago, Draco18s said:

Lore doesn't actually make the item any different. It's just text displayed in a tooltip.

You can modify the text displayed by subscribing to the ItemTooltipEvent, but adding "Crit chance: 5%"  won't actually make the item have a 5% crit chance.

For actual effects, some of them can be handled via AttributeModifiers which can be applied via NBT tags on item stacks. But this is a very limited set of effects (namely, attack damage and attack speed).

I know, i can make my own stat and dmg system that makes use of that text on items.

 

Hm, itemtooltipevent? Can't i first give the item lore and then make it drop from a mob? The attributes are too limiting. 

 

I already made the stat system for a bukkit server so i know it's possible, i just have to figure out the differences with forge modding 

Edited by robertx555
Link to comment
Share on other sites

1 hour ago, robertx555 said:

I already made the stat system for a bukkit server so i know it's possible, i just have to figure out the differences with forge modding

Not everything Bukkit does has a Forge equivalent and vice versa.

You can add other tags and write your code to handle interpreting what they do, but each one will need separate code and possible their own event hooks.

That is: making a critical damage stat and applying it to weapons and hooking into the right events, sure, its doable. It's just not two lines of code.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

Not everything Bukkit does has a Forge equivalent and vice versa.

You can add other tags and write your code to handle interpreting what they do, but each one will need separate code and possible their own event hooks.

That is: making a critical damage stat and applying it to weapons and hooking into the right events, sure, its doable. It's just not two lines of code.

 

Yeah i'm prepared to write code for many days.. but first i need to figure out how to add lore to items. I think i'm close to the answer, seems to be NBTTagList. I'll just fiddle with it until i figure it out 

Link to comment
Share on other sites

No, you really should not be doing that (modifying the actual ItemStack on the server).  Stop thinking like a Bukkit developer - you have access to both client and server here.

 

Never mind that, I misread.  If you're storing the functional data server-side using NBT and using Item#addInformation() clientside to display it to the player in a readable way, that's good.

 

To add "lore" (and that's really a Bukkit term - it's just a tooltip here), all you need to do is one of:

  1. If it's an item from your mod, override Item#addInformation() and append your text to the item's tooltip.
  2. If it's an item from another mod (or vanilla), you can use the clientside ItemTooltipEvent to insert your tooltip.

Remember, this is all happening on the client.  Tooltips are just information that is displayed to the player, not actually stored in a server-side item stack.  And your clientside code also has access to I18n.format() so you can correctly localize your tooltips.

Edited by desht
Link to comment
Share on other sites

Thanks, i figured out how to do it! I don't think i have the best possible way but it works!

 

First you add the tags

 

NBTTagCompound com = new NBTTagCompound();

 

com.setString("stats", "example stat");


item.setTagCompound(com);

 

then you display them

 


    @SubscribeEvent
    public void onTooltip(ItemTooltipEvent event) {


        ItemStack item = event.getItemStack();


    if (item.getTagCompound()!= null) {
            if (item.getTagCompound().hasKey("stats")) {
                event.getToolTip().add(stats);        

}

}

 

I got stuck because there wasn't setTooltip() method, i had to gettooltip() and then add().. You can also remove some of the tags from showing this way but attack speed and armor seems to stay lol

 

 

 

Link to comment
Share on other sites

2 hours ago, robertx555 said:

I got stuck because there wasn't setTooltip() method, i had to gettooltip() and then add().. You can also remove some of the tags from showing this way but attack speed and armor seems to stay lol

event.getToolTip() is correct. The list returned is a reference, so adding to the list will work.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
  • Topics

×
×
  • Create New...

Important Information

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