Immersive Intelligence

Immersive Intelligence

2M Downloads

[BUG] ItemStack-setting arithmetic logic expressions corrupt original value

Hawk777 opened this issue ยท 0 comments

commented

Describe the bug
When using one of the operations in the arithmetic logic machine that modifies an item stack, the original item stack is also modified, not just the value assigned to the result variable.

To Reproduce
Steps to reproduce the behavior:

  1. Connect a conveyor scanner to the input of an arithmetic logic machine.
  2. Connect a debugger to the output of the arithmetic logic machine.
  3. Place an ItemStack Operations circuit in the machine.
  4. Add the expression a = Set Quantity(%i%, 7) to the circuit.
  5. Feed one block of stone into the scanner.

Expected behavior
The debugger should print out a data packet with the i variable containing one stone (the value from the scanner) and the a variable containing seven stone (the result of the expression in the arithmetic logic machine).

** Actual behavior**
The debugger prints out a data packet where both a and i contain seven stone. This is because the execute function in DataOperationSetQuantity does not clone the ItemStack before modifying it and therefore modifies the object in the i variable. The same problem exists in DataOperationSetDurability.

Environment

  • OS: Linux
  • Minecraft version: 1.12.2
  • Forge version: 14.23.5.2854
  • Immersive Intelligence version: 0.1.1
  • Immersive Engineering version: 0.12-98