Jump to content

Damage increase only applying once


DrNickenstein

Recommended Posts

Could someone help me understand why the damage increment is applying only once in this class?

https://github.com/DrNickenstein/End-Adventure/blob/master/src/main/java/io/github/drnickenstein/endadventure/items/tools/swords/FinisiumSword.java

I'm afraid I don't know due to my lack of knowledge on the subject, if you can't or won't bother to explain, could you point me to where I could read something to learn about attribute modifiers?

Link to comment
Share on other sites

Quote

if you can't or won't bother to explain, could you point me to where I could read something to learn about attribute modifiers?

Look at the implementation of the method you are using.

It adds the information to a CompoundTag (a map of name->value) with the key in this case being the attribute name.

So any additional "adds" for the same attribute name will just overwrite the previous one.

 

Also, your implementation is complete rubbish.

Items are singletons. There is only ever one them.

Your hits and swordStage will be shared by all swords in the game and so they will overwrite each others data.

Instance data for items should be stored in the ItemStack NBT data like the attribute overrides you are playing with, or enchantments or item damage, etc.

Use getOrCreateTagElement(modId) to create your own unique tag on the ItemStack to store this data.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

3 hours ago, warjort said:

Instance data for items should be stored in the ItemStack NBT data like the attribute overrides you are playing with, or enchantments or item damage, etc.

Use getOrCreateTagElement(modId) to create your own unique tag on the ItemStack to store this data.

I'm sorry but I'm not very familiar with this kind of concepts yet, could you point me to some documentation about them? I can't find anything about NBTs or CompoundTags on the forge docs

Link to comment
Share on other sites

NBT is a minecraft concept Similar to json. https://minecraft.fandom.com/wiki/NBT_format#:~:text=The Named Binary Tag (NBT,Binary Tag (SNBT) format.

Pretty much all data is stored directly or indirectly in NBT.

The forge documentation mostly concentrates on what forge changes rather than trying to document minecraft.

If you expect minecraft to be documented, you will disappointed. It is a closed source project not designed to be modded (except by datapacks).

You need to do as other modders do. Read the vanilla source to find things similar to what you want to do or if you can't, find other mods instead.

 

Many modders will code this kind of processing as a serializable capability, so you can use java most of the time and only deal with NBT at load/save time:

https://forge.gemwire.uk/wiki/Capabilities

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

4 minutes ago, warjort said:

NBT is a minecraft concept Similar to json. https://minecraft.fandom.com/wiki/NBT_format#:~:text=The Named Binary Tag (NBT,Binary Tag (SNBT) format.

The forge documentation mostly concentrates on what forge changes rather than trying to document minecraft.

If you expect minecraft to be documented, you will disappointed. It is a closed source project not designed to be modded (except by datapacks).

You need to do as other modders do. Read the vanilla source to find things similar to what you want to do or if you can't, find other mods instead.

 

Many modders will code this kind of processing as a serializable capability, so you can use java most of the time and only deal with NBT at load/save time:

https://forge.gemwire.uk/wiki/Capabilities

Yeah I read it on that wiki but everything seems so abstract and reading it is a bit confusing to be honest

I would look for the source code of a mod if I had a broad knowledge of mods and their features, I legit couldn't even name one mod that does something similiar to what I'm trying to do even though something this basic is probably done by hundreds of mods.

Thank you for the sources provided, it's kinda sad that a game kept alive for a good part (may I say, mostly) by mods doesn't have an official documentation

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.