Open repo-alt opened 4 years ago
i've had to fix numerous very difficult inventory issues due to ic2 before. i see in your ref'd ticket some code and screenshots. when i get around to testing your PR i'll also poke at this
Thanks. Yes I saw a workaround for ic2 tools there.
There is one more bug with exactly same cause - when applying ic2 crop tile to an empty crop tile (for cross breeding), the stack of 1 crop cannot be applied, because it crashes trying to set
player.inventory.mainInventory[player.inventory.currentItem] = null;
where player.inventory.currentItem is -1 because it is from equipment inventory.
(In general the trick with setting player.inventory.currentItem to -1 for equipment slot looks rather fragile (unfortunately I cannot suggest better alternative for 1.7.10))
The best solution would be to write an inventory proxy which combines two inventories (mainInventory and equipmentInventory), then rewrite agent.Player to use that.
Illustrations here: https://github.com/GTNewHorizons/NewHorizons/issues/5657
The reason is that ic2 crop seed onItemUse tries to set
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null;
but for the robot entityplayer.inventory.currentItem is not set (probably due to tool belt/main inventory distinction)I understand that direct access to the player inventory is not a good idea on ic2 side but it is somehow unlikely that they will fix it, so, do you have any idea how to circumvent it on OC side? Because all I can think of is another hack in li.cil.oc.server.agent.Player.activateBlockOrUseItem