mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Merge branch 'master-MC1.10' into master-MC1.11
# Conflicts: # src/main/scala/li/cil/oc/util/InventoryUtils.scala
This commit is contained in:
commit
b3f33c92e8
@ -183,10 +183,11 @@ class Player(val agent: internal.Agent) extends FakePlayer(agent.world.asInstanc
|
||||
private def collectDroppedItems(itemsBefore: Iterable[EntityItem]) {
|
||||
val itemsAfter = adjacentItems
|
||||
val itemsDropped = itemsAfter -- itemsBefore
|
||||
for (drop <- itemsDropped) {
|
||||
drop.setNoPickupDelay()
|
||||
drop.onCollideWithPlayer(this)
|
||||
drop.setDead()
|
||||
if (itemsDropped.nonEmpty) {
|
||||
for (drop <- itemsDropped) {
|
||||
drop.setNoPickupDelay()
|
||||
drop.onCollideWithPlayer(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,11 +293,20 @@ trait Agent extends traits.WorldControl with traits.InventoryControl with traits
|
||||
entity.captureDrops = true
|
||||
}
|
||||
|
||||
|
||||
protected def endConsumeDrops(player: Player, entity: Entity) {
|
||||
entity.captureDrops = false
|
||||
for (drop <- entity.capturedDrops) {
|
||||
val stack = drop.getEntityItem
|
||||
InventoryUtils.addToPlayerInventory(stack, player)
|
||||
// this inventory size check is a HACK to preserve old behavior that a agent can suck items out
|
||||
// of the capturedDrops. Ideally, we'd only pick up items off the ground. We could clear the
|
||||
// capturedDrops when Player.attackTargetEntityWithCurrentItem() is called
|
||||
// But this felt slightly less hacky, slightly
|
||||
if (player.inventory.getSizeInventory > 0) {
|
||||
for (drop <- entity.capturedDrops) {
|
||||
if (!drop.isDead) {
|
||||
val stack = drop.getEntityItem
|
||||
InventoryUtils.addToPlayerInventory(stack, player, spawnInWorld = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
entity.capturedDrops.clear()
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ object InventoryUtils {
|
||||
/**
|
||||
* Try inserting an item stack into a player inventory. If that fails, drop it into the world.
|
||||
*/
|
||||
def addToPlayerInventory(stack: ItemStack, player: EntityPlayer): Unit = {
|
||||
def addToPlayerInventory(stack: ItemStack, player: EntityPlayer, spawnInWorld: Boolean = true): Unit = {
|
||||
if (!stack.isEmpty) {
|
||||
if (player.inventory.addItemStackToInventory(stack)) {
|
||||
player.inventory.markDirty()
|
||||
@ -373,7 +373,7 @@ object InventoryUtils {
|
||||
player.openContainer.detectAndSendChanges()
|
||||
}
|
||||
}
|
||||
if (stack.getCount > 0) {
|
||||
if (stack.getCount > 0 && spawnInWorld) {
|
||||
player.dropItem(stack, false, false)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user