fix: incorrect usage of canTakeItem
This commit is contained in:
parent
40ed66d76e
commit
f3be1aae48
@ -68,7 +68,7 @@ class ExchangeItem<E> : Behavior<E>(
|
|||||||
private fun exchangeItems(level: ServerLevel, entity: E) {
|
private fun exchangeItems(level: ServerLevel, entity: E) {
|
||||||
val container = level.getBlockEntity(target!!) as Container
|
val container = level.getBlockEntity(target!!) as Container
|
||||||
val inventory = entity.inventory
|
val inventory = entity.inventory
|
||||||
for (i in 1..6) {
|
for (i in 1..10) {
|
||||||
val maxCount = 1 + level.random.nextInt(16)
|
val maxCount = 1 + level.random.nextInt(16)
|
||||||
if (level.random.nextBoolean()) {
|
if (level.random.nextBoolean()) {
|
||||||
// take
|
// take
|
||||||
@ -77,7 +77,7 @@ class ExchangeItem<E> : Behavior<E>(
|
|||||||
if (!item.isEmpty) {
|
if (!item.isEmpty) {
|
||||||
val takeCount = min(item.count, maxCount)
|
val takeCount = min(item.count, maxCount)
|
||||||
val takeItem = item.copyWithCount(takeCount)
|
val takeItem = item.copyWithCount(takeCount)
|
||||||
if (inventory.canTakeItem(container, slot, takeItem) && entity.canHoldItem(takeItem)) {
|
if (entity.canHoldItem(takeItem)) {
|
||||||
val remaining = inventory.addItem(/*entity.equipItemIfPossible(takeItem)*/ takeItem)
|
val remaining = inventory.addItem(/*entity.equipItemIfPossible(takeItem)*/ takeItem)
|
||||||
val actualCount = takeCount - remaining.count
|
val actualCount = takeCount - remaining.count
|
||||||
item.shrink(actualCount)
|
item.shrink(actualCount)
|
||||||
@ -91,7 +91,6 @@ class ExchangeItem<E> : Behavior<E>(
|
|||||||
if (!item.isEmpty) {
|
if (!item.isEmpty) {
|
||||||
val takeCount = min(item.count, maxCount)
|
val takeCount = min(item.count, maxCount)
|
||||||
val takeItem = item.copyWithCount(takeCount)
|
val takeItem = item.copyWithCount(takeCount)
|
||||||
if (container.canTakeItem(inventory, slot, takeItem)) {
|
|
||||||
for (target in 0 until container.containerSize) {
|
for (target in 0 until container.containerSize) {
|
||||||
val targetItem = container.getItem(target)
|
val targetItem = container.getItem(target)
|
||||||
if (ItemStack.isSameItemSameTags(targetItem, takeItem)) {
|
if (ItemStack.isSameItemSameTags(targetItem, takeItem)) {
|
||||||
@ -120,7 +119,6 @@ class ExchangeItem<E> : Behavior<E>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
container.setChanged()
|
container.setChanged()
|
||||||
inventory.setChanged()
|
inventory.setChanged()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user