devrun: add ability to fill inventories with same item

This commit is contained in:
deirn 2023-02-07 00:18:48 +07:00
parent fcab1a0058
commit 0042776294
No known key found for this signature in database
GPG key ID: AFBDA9A393789F08

View file

@ -32,7 +32,10 @@ object StorageFillerItem : Item(ModItem.SETTINGS) {
val storage = ItemStorage.SIDED.find(world, pos, Direction.UP)
if (storage != null) Transaction.openOuter().use { transaction ->
while (true) {
val item = Registries.ITEM.getRandom(world.random).get().value()
val item =
if (!player.offHandStack.isEmpty) player.offHandStack.item
else Registries.ITEM.getRandom(world.random).get().value()
if (storage.insert(ItemVariant.of(item), item.maxCount.toLong(), transaction) == 0L) break
}
transaction.commit()