KubeJS

KubeJS

107M Downloads

Custom Weapons/Tools refuse to apply maxDamage() method to change item durability (NeoForge 1.21.1)

Scarlet-Fury opened this issue ยท 3 comments

commented

Minecraft Version

1.21.1

KubeJS Version

KubeJS NeoForge 2101.7.1-build.181

Rhino Version

Rhino 2101.2.7-build.77

Architectury Version

[NeoForge 1.21(.1)]v13.0.8

Forge/Fabric Version

NeoForge - 21.1.208

Describe your issue

So, at first, I thought this was an issue with the add-on KubeJS Delight, and reported the issue over there (See link here): QinomeD/kubejsdelight#19

But then the author of KubeJS Delight tried using my same script for a sword and had the same problem, so I'm reporting it here too

Basically, regardless of the order in which I do things, this script (Which is supposed to create a Steel Knife for Farmer's Delight compatibility with Immersive Engineering) refuses to apply the custom durability of 641 to the knife. Immersive Engineering uses the custom durability of 641 for all Steel tier tools, so I thought using maxDamage(641) would apply this durability... Unfortunately this didn't work. So I tried adding a tier to it, thinking maybe that would help it, and then apply the durability after the tier (Such as iron or diamond)

This also didn't work, and the resulting knife only had either Iron level durability (250) or Diamond level (1561)

This happened regardless of whether I included a tier method of any sort, or where in the script the method fired first

I'm not sure why this is behaving this way, but here's my current script:


console.info('Wildborne KubeJS Startup Script - Steel Knife Tool Loaded')


StartupEvents.registry('item', event => {

  event.create('steel_knife', 'farmersdelight:knife')

    .displayName('Steel Knife')

    .tier('diamond')

    .maxDamage(641)

});

I hope this can be fixed soon, as I love using KubeJS to implement all sorts of great little things to continue expanding the world of the modpack I'm developing!

On a side note, any CUSTOM REGULAR OLD items I made using KubeJS startup scripts (Such as a Charcoal Water Filter) DOES apply the maxDamage item durability method properly and works wonders... which is weird... Is it an issue within the item constructor itself?

Anyhay, thanks for all you do, and I hope it can be fixed soon! ^^

Crash report/logs

No response

commented

Tiered Items get the damage from uses from Tier, so maxDamage does nothing.

Since you already have that tier from somewhere, just do this so you can save youself from creating a tier

let $Lib = Java.loadClass("blusunrize.immersiveengineering.api.Lib")

StartupEvents.registry('item',event=> {
    event.create('ie_tiered_sword', 'sword')
      .tier($Lib.MATERIAL_Steel)
})
Image
commented

Gotcha, I'll try that

commented

IT WORKED! Thank you so much!

I'm gonna need to remember this way for future scripts ^^

Tiered Items get the damage from uses from Tier, so maxDamage does nothing.

Since you already have that tier from somewhere, just do this so you can save youself from creating a tier

let $Lib = Java.loadClass("blusunrize.immersiveengineering.api.Lib")

StartupEvents.registry('item',event=> {
    event.create('ie_tiered_sword', 'sword')
      .tier($Lib.MATERIAL_Steel)
})
Image