Problems with adding armor tiers and items
copygirl opened this issue ยท 7 comments
Description
There are multiple problems with creating additional armor tiers and associated items:
- Documentation is incorrect about slot indices
-
durabilityMultiplier
is never used - Using tag in
repairIngredients
results in an error
Documentation is incorrect about slot indices
First of all there appears to be something wrong with the documentation, here an excerpt from the Custom Items page:
// Slot indicies are [HEAD, BODY, LEGS, FEET] event.add('tier_id', tier => { tier.durabilityMultiplier = 15 // Each slot will be multiplied with [13, 15, 16, 11] tier.slotProtections = [2, 5, 6, 2]
The slot indices (both for durabilityMultipier
as well as slotProtections
) are actually in the order FEET, LEGS, CHEST, HEAD.
durabilityMultiplier
is never used
Any armor item created with a custom armor tier will always have a durability of 300 regardless of the durabilityMultiplier
set, unless maxDamage
is called on the item builder manually. The durability is set in ItemType.applyDefaults
when .type()
is called.
Additionally it's not quite clear (except through trial-and-error or looking at the source code) that .tier()
must be called after .type()
. Perhaps this can be resolved together.
Using tag in repairIngredients
results in an error
[11:49:27] [ERR ] Error occurred while handling event 'item.registry.armor_tiers': Wrapped java.lang.IllegalStateException: Tag forge:plates/enderium used before it was bound (startup_scripts:armor.js#27)
This appears to be the case because at item registry time, tags are not yet available, resulting in IngredientJS.createVanillaIngredient()
to fail as, presumably, it tries to access all items in a tag..?
Example code
// kubejs/startup_scripts/armor.js
onEvent("item.registry.armor_tiers", event => {
event.add("enderium", tier => {
tier.durabilityMultiplier = 35; // Not applied!
tier.slotProtections = [ 3, 6, 8, 3 ]; // FEET, LEGS, CHEST, HEAD!
tier.toughness = 2.5;
tier.knockbackResistance = 0.1;
tier.enchantmentValue = 20;
tier.repairIngredient = "#forge:plates/enderium"; // Causes error!
});
});
onEvent("item.registry", event => {
// Without calling maxDamage, all armor will have 300 durability.
event.create("enderium_helmet" ).displayName("Enderium Helmet" ).type("helmet" ).tier("enderium"); //.maxDamage(35 * 13);
event.create("enderium_chestplate").displayName("Enderium Chestplate").type("chestplate").tier("enderium"); //.maxDamage(35 * 16);
event.create("enderium_leggings" ).displayName("Enderium Leggings" ).type("leggings" ).tier("enderium"); //.maxDamage(35 * 15);
event.create("enderium_boots" ).displayName("Enderium Boots" ).type("boots" ).tier("enderium"); //.maxDamage(35 * 11);
});
Versions
Minecraft: 1.16.5
Forge: 36.2.0
KubeJS: 1605.3.15-build.100
Just as a note, Ingredient.of
has an overload that takes Tag<Item>
. That could be used when creating the repair ingredient using a tag.
It is worth adding, the problem also occurs on the fabric version.
Minecraft: 1.16.5
Fabric: 0.11.7
KubeJS: 1605.3.18-build.144
Custom armor textures also don't appear to be working, it always uses minecraft's iron armor textures.
ays uses minecraft's iron armor tex
That just means you didn't set it up properly. Textures do work.
I haven't been able to see what I'm doing wrong at all. Here's my start-up script:
//kubejs/startup_scripts/deprecated_knightmetal.js
onEvent('item.registry.armor_tiers', event => {
event.add('deprecated_knightmetal', tier => {
tier.durabilityMultiplier = 500
tier.slotProtections = [2, 5, 4, 1]
tier.enchantmentValue = 9
tier.equipSound = 'minecraft:item.armor.equip_iron'
tier.repairIngredient = '#forge:ingots/ironwood'
tier.toughness = 0.0
tier.knockbackResistance = 0.0
})
})
onEvent('item.registry', event => {
event.create('deprecated_knightmetal_helmet')
.displayName('Deprecated Knightmetal Helmet')
.type('helmet')
.tier('deprecated_knightmetal')
event.create('deprecated_knightmetal_chestplate')
.displayName('Deprecated Knightmetal Chestplate')
.type('chestplate')
.tier('deprecated_knightmetal')
event.create('deprecated_knightmetal_leggings')
.displayName('Deprecated Knightmetal Leggings')
.type('leggings')
.tier('deprecated_knightmetal')
event.create('deprecated_knightmetal_boots')
.displayName('Deprecated Knightmetal Boots')
.type('boots')
.tier('deprecated_knightmetal')
})
My textures file-path is kubejs\assets\kubejs\textures\models\armor
, with both layers being named deprecated_knightmetal_layer_1.png
and deprecated_knightmetal_layer_2
. I cannot see what I'm doing wrong.
Edit: After a bit more testing, I don't think the item registry respects the tier given at all. The armor will always use the Iron tier, regardless of my input. Even when putting a built-in tier like chainmail
, I still cannot get it to use that tier.
Edit: My issues were because I never removed repairIngredients
, whoops
There's your issue, the textures have to be in kubejs\assets\minecraft\textures\models\armor
. :)