#Keeping current enchantments on a weapon when its used in crafting another weapon

22 messages · Page 1 of 1 (latest)

midnight ferry
#

Im currently modifying some crafting recipies in ATM7 and wanted to make it so I can either A make a shaped crafting of netherite to Allthemodium tools or B use create sequenced assembly to upgrade. Ive gotten it to go from a standard netherite sword to a standard allthemodium sword both ways but I cant use an enchanted netherite sword and upgrade it into a allthemodium sword with the same enchants. I wanted it to accept any enchant on the sword and move it to the new one. Any help would be appreciated current code:

onEvent('recipes', e => {
//SWORDS
e.recipes.createSequencedAssembly([
Item.of('allthemodium:allthemodium_sword').withChance(100.0)
], 'minecraft:netherite_sword', [
e.recipes.createDeploying('create:incomplete_precision_mechanism', ['create:incomplete_precision_mechanism', 'allthemodium:allthemodium_rod']),
e.recipes.createDeploying('create:incomplete_precision_mechanism', ['create:incomplete_precision_mechanism', 'allthemodium:allthemodium_plate']),
e.recipes.createDeploying('create:incomplete_precision_mechanism', ['create:incomplete_precision_mechanism', 'allthemodium:allthemodium_plate']),
e.recipes.createPressing('create:incomplete_precision_mechanism', 'create:incomplete_precision_mechanism')
]).transitionalItem('create:incomplete_precision_mechanism').loops(1)

e.shaped('allthemodium:allthemodium_sword', [' P ', ' P ', ' S '], {
    P: 'allthemodium:allthemodium_plate',
    S: 'minecraft:netherite_sword'
})

})

weary totemBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

chrome cliff
#

On the shapeless recipe you can use modifyResult for the create sequenced assembly you can't keep enchantments

plucky violetBOT
#
event.shaped(...).modifyResult((grid, result) => {
  let item = grid.find(Item.of("itemtotakenbtfrom"))
  return result.withNBT(item.nbt)
})
midnight ferry
#

I think im following but i went to try and apply this and it still doesnt want to accept an enchanted sword as an input for shaped crafting: e.shaped('allthemodium:allthemodium_sword', [' P ', ' P ', ' S '], {
P: 'allthemodium:allthemodium_plate',
S: 'minecraft:netherite_sword'
}).modifyResult((grid, result) => {
let item = grid.find(Item.of("minecraft:netherite_sword"))
return result.withNBT(item.nbt)
})

chrome cliff
#

oh you probably need to add Item.of("item_id").ignoreNBT() for your script which adds the main recipe

midnight ferry
#

would this be for assigning the letter so S: 'minecraft:netherite_sword' becomes S: Item.of('minecraft:netherite_sword').ignoreNBT

chrome cliff
#

yes, though I forgot to write the brackets at the end of the ingnore NBT, I have added them now

midnight ferry
#

its easy to pick up once you know the actual commands lol I appreciate you helping me so far

#

so it seems to craft but not keep the enchantment.

plucky violetBOT
#

Here's a list of some of the most common KubeJS errors and their fixes (WIP):

chrome cliff
#

ignore that

plucky violetBOT
#

You can find your KubeJS server log in /minecraft/logs/kubejs/server.log.
If you are on 1.18 or below it will be called server.txt.
Please send it if asked, as it contains helpful information.

midnight ferry
plucky violetBOT
#

Paste version of server.txt from @midnight ferry

chrome cliff
#

you probably need this actually

e.shaped('allthemodium:allthemodium_sword', [' P ', ' P ', ' S '], {
    P: 'allthemodium:allthemodium_plate',
    S: Item.of("minecraft:netherite_sword").ignoreNBT()
}).modifyResult((grid, result) => {
    let item = grid.find(Item.of("minecraft:netherite_sword").ignoreNBT())
    return result.withNBT(item.nbt)
})
midnight ferry
#

ok that gets us back to not being able to craft with the enchanted sword

chrome cliff
#

oh shit I forgot the change in the S key, sorry for making lots of mistakes. Try it now.

midnight ferry
#

thats it!

#

I appreciate it