Merge branch master-MC1.11 into master-MC1.12

This commit is contained in:
payonel 2017-10-03 12:27:02 -07:00
commit 1659af29b0
2 changed files with 16 additions and 3 deletions

View File

@ -12,8 +12,11 @@ trait ItemStackInventory extends Inventory {
override def items = inventory
// Initialize the list automatically if we have a container.
if (!container.isEmpty) {
reinitialize()
{
val _container = container
if (_container != null && !_container.isEmpty) {
reinitialize()
}
}
// Load items from tag.

View File

@ -213,12 +213,22 @@ class Player(val agent: internal.Agent) extends FakePlayer(agent.world.asInstanc
private var offHand: (IInventory, Int) = _
override def setItemStackToSlot(slotIn: EntityEquipmentSlot, stack: ItemStack): Unit = {
var superCall: () => Unit = () => super.setItemStackToSlot(slotIn, stack)
if (slotIn == EntityEquipmentSlot.MAINHAND) {
agent.equipmentInventory.setInventorySlotContents(0, stack)
superCall = () => {
val slot = inventory.currentItem
// So, if we're not in the main inventory, currentItem is set to -1
// for compatibility with mods that try accessing the inv directly
// using inventory.currentItem. See li.cil.oc.server.agent.Inventory
if(inventory.currentItem < 0) inventory.currentItem = ~inventory.currentItem
super.setItemStackToSlot(slotIn, stack)
inventory.currentItem = slot
}
} else if(slotIn == EntityEquipmentSlot.OFFHAND && offHand != null) {
offHand._1.setInventorySlotContents(offHand._2, stack)
}
super.setItemStackToSlot(slotIn, stack)
superCall()
}
override def getItemStackFromSlot(slotIn: EntityEquipmentSlot): ItemStack = {