MightyPirates / OpenComputers

Home of the OpenComputers mod for Minecraft.
https://oc.cil.li
Other
1.59k stars 432 forks source link

Robot dupes ic2 seed bags #3236

Open repo-alt opened 4 years ago

repo-alt commented 4 years ago

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

payonel commented 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

repo-alt commented 4 years ago

Thanks. Yes I saw a workaround for ic2 tools there.

repo-alt commented 4 years ago

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))

asiekierka commented 2 years ago

The best solution would be to write an inventory proxy which combines two inventories (mainInventory and equipmentInventory), then rewrite agent.Player to use that.