KubeJS (Old)

KubeJS (Old)

3M Downloads

Failed in attribute modification for mod weapon

sssssLug opened this issue · 4 comments

commented

Minecraft Version

1.19.2

KubeJS Version

1902.6.0-build.135

Rhino Version

1902.2.2-build.264

Architectury Version

6.3.56

Forge/Fabric Version

Forge 43.1.52

Describe your issue

My code is written as:
ItemEvents.modification(event => {
event.modify('savage_and_ravage:cleaver_of_beheading', modification => {
modification.setAttackDamage(16)
})
})
Then the game couldn't start, and the startup.txt shows the error like "removing attribute in unsupported item", while the item is actually regarded as a "weapon" by the game and other mods.
startup.txt
crash-2022-12-24_20.50.37-fml.txt
latest.log

Crash report/logs

No response

commented

To modify an items attributes KubeJS needs a particular interface mixined to them. KubeJS specifically adds this to many vanilla item types (swords, shovels, pickaxes, tridents). This means that mods that use that type to make their item also support modification.
However, Savage and Ravage use a custom class for their cleaver item, and so it is not supported there. I also do not think KubeJS would implement special support for mods items like that.

I do notice it is a tiered item though, so you may have some luck with modifying its tier like so:

ItemEvents.modification(event => {
  event.modify('savage_and_ravage:cleaver_of_beheading', modification => {
    modification.tier = tierModification => {
      tierModification.attackDamageBonus = 14
    }
  })
})
commented

To modify an items attributes KubeJS needs a particular interface mixined to them. KubeJS specifically adds this to many vanilla item types (swords, shovels, pickaxes, tridents). This means that mods that use that type to make their item also support modification. However, Savage and Ravage use a custom class for their cleaver item, and so it is not supported there. I also do not think KubeJS would implement special support for mods items like that.

I do notice it is a tiered item though, so you may have some luck with modifying its tier like so:

ItemEvents.modification(event => {
  event.modify('savage_and_ravage:cleaver_of_beheading', modification => {
    modification.tier = tierModification => {
      tierModification.attackDamageBonus = 14
    }
  })
})

Got it , thank you very much.
And can I create a custom tool type by kubejs?

commented

You can make copies of existing items through some reflection, but not entirely new types.

commented

Thank you again.And I'm unlucky as the code didn't work.That doesn't matter.