diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt index e3c76b269..711a617e4 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/storage/StorageBusBlockEntity.kt @@ -46,6 +46,7 @@ import kotlin.collections.HashMap private class SlotTuple(val slot: Int, val stack: ItemStack) private class TrackedTuple(override val stack: ItemStackWrapper, override val id: UUID) : IStorageTuple { + // do not use hash map because we need keys to be iterated in natural order val children = Int2ObjectAVLTreeMap() override fun toString(): String { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt index 7b6f5853e..8826ac809 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/AndroidStationScreen.kt @@ -6,6 +6,7 @@ import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.Int2FloatAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectFunction +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.Minecraft import net.minecraft.network.chat.Component @@ -524,7 +525,7 @@ class AndroidStationScreen constructor(p_97741_: AndroidStationMenu, p_97742_: I MatteryScreen(p_97741_, p_97742_, p_97743_) { private fun makeCanvas(isPreview: Boolean): DraggableCanvasPanel { - val rows = Int2ObjectAVLTreeMap>() + val rows = Int2ObjectOpenHashMap>() val canvas = object : DraggableCanvasPanel(this@AndroidStationScreen, null) { private val random = Random() diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index b2e6876cb..01a6a3f8c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem import com.mojang.blaze3d.vertex.PoseStack import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectFunction +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.ChatFormatting import net.minecraft.client.gui.Font import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen @@ -63,7 +64,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - private val inventorySlotsRows = Int2ObjectAVLTreeMap>>() + private val inventorySlotsRows = Int2ObjectOpenHashMap>>() private lateinit var slotListCanvas: EditablePanel> private lateinit var inventoryScrollbar: DiscreteScrollBarPanel> diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt index c2d865db0..2e1a2afdc 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/compat/ExtendedInventoryHandler.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.mc.otm.compat import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap import it.unimi.dsi.fastutil.ints.Int2ObjectFunction +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.objects.ReferenceArraySet import net.minecraft.network.FriendlyByteBuf import net.minecraft.world.SimpleContainer @@ -37,7 +38,7 @@ private class MenuConfiguration( } private val slotPositions = Int2ObjectArrayMap>() - private val rows = Int2ObjectAVLTreeMap>() + private val rows = Int2ObjectOpenHashMap>() val isIncomplete: Boolean private fun getRow(index: Int, matteryPlayer: MatteryPlayerCapability) = rows.computeIfAbsent(index, Int2ObjectFunction { @@ -200,6 +201,7 @@ class InventoryScrollPacket(val scroll: Int) : MatteryPacket { } menuConfigurations.computeIfAbsent(containerMenu) { + // do not use hash map because we need keys be iterated in natural order val originalSlots = Int2ObjectAVLTreeMap() for (slot in it.slots) { diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt index 17522dfd7..251540c89 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/menu/data/NetworkedItemView.kt @@ -2,6 +2,7 @@ package ru.dbotthepony.mc.otm.menu.data import com.mojang.blaze3d.platform.InputConstants import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.client.Minecraft import net.minecraft.client.gui.screens.Screen import net.minecraft.network.FriendlyByteBuf @@ -205,7 +206,7 @@ open class NetworkedItemView(val ply: Player, val menu: MatteryMenu, val remote: get() = ITEM_STORAGE // this (how client see and interact with) - val localState = Int2ObjectAVLTreeMap() + val localState = Int2ObjectOpenHashMap() val sortedView = LinkedList() var sorter: Comparator = NAME_SORTER diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt index 7043a50d4..a62f5e1a8 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/network/FieldSynchronizer.kt @@ -1,6 +1,8 @@ package ru.dbotthepony.mc.otm.network import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap +import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap +import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import it.unimi.dsi.fastutil.io.FastByteArrayInputStream import it.unimi.dsi.fastutil.io.FastByteArrayOutputStream import it.unimi.dsi.fastutil.objects.ObjectArraySet @@ -1064,9 +1066,9 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa return values } - private val idToField = Int2ObjectAVLTreeMap>() + private val idToField = Int2ObjectOpenHashMap>() private val missingFields = ObjectArraySet() - private val missingFieldsMap = Int2ObjectAVLTreeMap() + private val missingFieldsMap = Int2ObjectArrayMap() fun applyNetworkPayload(stream: InputStream): Int { if (stream.read() > 0) {