Add IEnhancedContainer specific optimization
This commit is contained in:
parent
65bbc56014
commit
9f8e7693a8
@ -9,6 +9,7 @@ import net.minecraft.world.item.ItemStack
|
|||||||
import net.minecraft.world.level.storage.loot.LootParams
|
import net.minecraft.world.level.storage.loot.LootParams
|
||||||
import net.minecraft.world.level.storage.loot.LootTable
|
import net.minecraft.world.level.storage.loot.LootTable
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
|
import ru.dbotthepony.mc.otm.container.IEnhancedContainer
|
||||||
import ru.dbotthepony.mc.otm.container.get
|
import ru.dbotthepony.mc.otm.container.get
|
||||||
import ru.dbotthepony.mc.otm.container.set
|
import ru.dbotthepony.mc.otm.container.set
|
||||||
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
import ru.dbotthepony.mc.otm.core.isNotEmpty
|
||||||
@ -105,9 +106,14 @@ private fun shuffle(items: MutableList<ItemStack>, emptySlotCount: Int, random:
|
|||||||
fun LootTable.fill(params: LootParams, random: RandomSource, container: Container, rounds: Int = 1) {
|
fun LootTable.fill(params: LootParams, random: RandomSource, container: Container, rounds: Int = 1) {
|
||||||
val emptySlots = IntArrayList()
|
val emptySlots = IntArrayList()
|
||||||
|
|
||||||
for (i in 0 until container.containerSize)
|
if (container is IEnhancedContainer<*>) {
|
||||||
if (container[i].isEmpty)
|
for (i in container.emptySlotIndexIterator())
|
||||||
emptySlots.add(i)
|
emptySlots.add(i)
|
||||||
|
} else {
|
||||||
|
for (i in 0 until container.containerSize)
|
||||||
|
if (container[i].isEmpty)
|
||||||
|
emptySlots.add(i)
|
||||||
|
}
|
||||||
|
|
||||||
emptySlots.shuffle(random)
|
emptySlots.shuffle(random)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user