withCapNBT returns unmodified IItemStack
RonanRaven opened this issue ยท 4 comments
Issue description
calling .withCapNBT(new_IData) does not return the object with updated CapNBT.
I've tried a couple of different variations, but I haven't been able to get any IItemStacks to properly change it's CapNBT.
Steps to reproduce
- setup forge 1.12.2 - 14.23.5.2859
- install related mods:
- TerraFirmaCraft-MC1.12.2-1.7.23.181.jar
- CraftTweaker2-1.12-4.1.20.679.jar
- add the script as 'tfc_test.zs'
- launch game
- check crafttweaker.log
Observed:
Calling withCapNBT DID NOT update the returned IItemStack object
Log lines contain the following
[INITIALIZATION][CLIENT][INFO] {Parent: {heat: 0.0 as float, metalAmount: 25, ticks: -1 as long, forge: {work: 0, steps: {last: -1, third: -1, second: -1}}, metal: "tfc:wrought_iron"}}
[INITIALIZATION][CLIENT][INFO] {Parent: {heat: 0.0 as float, metalAmount: 100, ticks: -1 as long, forge: {work: 0, steps: {last: -1, third: -1, second: -1}}, metal: "tfc:wrought_iron"}}
[INITIALIZATION][CLIENT][INFO] {Parent: {heat: 0.0 as float, metalAmount: 100, ticks: -1 as long, forge: {work: 0, steps: {last: -1, third: -1, second: -1}}, metal: "tfc:wrought_iron"}}
Expected:
Calling withCapNBT should update the returned IItemStack object
Log lines should contain the following
[INITIALIZATION][CLIENT][INFO] {Parent: {heat: 0.0 as float, metalAmount: 25, ticks: -1 as long, forge: {work: 0, steps: {last: -1, third: -1, second: -1}}, metal: "tfc:wrought_iron"}}
[INITIALIZATION][CLIENT][INFO] {Parent: {heat: 0.0 as float, metalAmount: 25, ticks: -1 as long, forge: {work: 0, steps: {last: -1, third: -1, second: -1}}, metal: "tfc:wrought_iron"}}
[INITIALIZATION][CLIENT][INFO] {Parent: {heat: 0.0 as float, metalAmount: 25, ticks: -1 as long, forge: {work: 0, steps: {last: -1, third: -1, second: -1}}, metal: "tfc:wrought_iron"}}
Script used
https://gist.github.com/RonanRaven/1c9f787ca09bfdedb685bbdfaef5b3c1
The crafttweaker.log file
https://gist.github.com/RonanRaven/cb716766ee893e9b4b6ddd4537bc698c
Minecraft version
1.12
Modloader
Forge
Modloader version
14.23.5.2859
CraftTweaker version
4.1.20.679
Other relevant information
No response
The latest.log file
N/A
I copied what you posted, but to no avail, it still prints the unchanged capability nbt.
I appreciate the suggestion, didn't realize it was by default an immutable object. I also tried a couple of other variants, just to see if it would work under other conditions of being mutable, shouldn't make a difference, and it didn't, all unchanged capability nbt's.
import crafttweaker.data.IData;
import crafttweaker.item.IItemStack;
import crafttweaker.item.IMutableItemStack;
var refined_nbt = <tfc:bloom/refined>.getCapNBT();
var refined_nbt_override = {
Parent: {
metalAmount: 25
}
} as IData;
var refined_nbt_new = refined_nbt + refined_nbt_override;
print(refined_nbt_new.asString());
var my_bloom = <tfc:bloom/refined>.mutable() as IMutableItemStack;
print(my_bloom.getCapNBT().asString());
print(my_bloom.withCapNBT(refined_nbt_new).getCapNBT().asString());
var mynew_bloom=my_bloom.withCapNBT(refined_nbt_new);
print(mynew_bloom.getCapNBT().asString());
@friendlyhj I believe you were the one who PRd the methods, do you have any idea?
Try using:
import crafttweaker.data.IData;
import crafttweaker.item.IItemStack;
var refined_nbt = <tfc:bloom/refined>.getCapNBT();
var refined_nbt_override = {
Parent: {
metalAmount: 25
}
} as IData;
var refined_nbt_new = refined_nbt + refined_nbt_override;
print(refined_nbt_new.asString());
var my_bloom = <tfc:bloom/refined>.mutable().withCapNBT(refined_nbt_new) as IItemStack;
print(my_bloom.getCapNBT().asString());
var mynew_bloom=my_bloom.withCapNBT(refined_nbt_new);
print(mynew_bloom.getCapNBT().asString());
and see what it prints?
Closed by 831d2e3