in case held item updates INHAND (e.g. milking a cow) move it to our offhand buffer as our agent code expects

closes #3200
This commit is contained in:
payonel 2021-05-13 06:49:11 -07:00
parent 481ae2f91a
commit 1178a90f80

View File

@ -226,10 +226,16 @@ class Player(val agent: internal.Agent) extends FakePlayer(agent.world.asInstanc
case living: EntityLivingBase if !getHeldItemMainhand.isEmpty => getHeldItemMainhand.interactWithEntity(this, living, hand)
case _ => false
}))
if (!getHeldItemMainhand.isEmpty && getHeldItemMainhand.getCount <= 0) {
val orig = getHeldItemMainhand
this.inventory.setInventorySlotContents(this.inventory.currentItem, ItemStack.EMPTY)
ForgeEventFactory.onPlayerDestroyItem(this, orig, hand)
if (!getHeldItemMainhand.isEmpty) {
if (getHeldItemMainhand.getCount <= 0) {
val orig = getHeldItemMainhand
this.inventory.setInventorySlotContents(this.inventory.currentItem, ItemStack.EMPTY)
ForgeEventFactory.onPlayerDestroyItem(this, orig, hand)
} else {
// because of various hacks for IC2, we expect the in-hand result to be moved to our offhand buffer
this.inventory.offHandInventory.set(0, getHeldItemMainhand)
this.inventory.setInventorySlotContents(this.inventory.currentItem, ItemStack.EMPTY)
}
}
result
})) EnumActionResult.SUCCESS else EnumActionResult.PASS