diff --git a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/InventoryViewer.kt b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/InventoryViewer.kt index 78e1b5f93..585526246 100644 --- a/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/InventoryViewer.kt +++ b/src/main/kotlin/com/lambda/client/gui/hudgui/elements/player/InventoryViewer.kt @@ -10,9 +10,15 @@ import com.lambda.client.util.graphics.VertexHelper import com.lambda.client.util.items.storageSlots import com.lambda.client.util.math.Vec2d import com.lambda.client.util.threads.runSafe +import net.minecraft.client.gui.inventory.GuiContainer import net.minecraft.client.renderer.GlStateManager import net.minecraft.client.renderer.Tessellator import net.minecraft.client.renderer.vertex.DefaultVertexFormats +import net.minecraft.init.Blocks +import net.minecraft.inventory.Container +import net.minecraft.inventory.ContainerChest +import net.minecraft.inventory.InventoryBasic +import net.minecraft.item.ItemStack import net.minecraft.util.ResourceLocation import org.lwjgl.opengl.GL11.* @@ -21,14 +27,15 @@ internal object InventoryViewer : HudElement( category = Category.PLAYER, description = "Items in Inventory" ) { + private val enderChest by setting("Inventory", SlotType.PLAYER) private val mcTexture by setting("Minecraft Texture", false) private val showIcon by setting("Show Icon", false, { !mcTexture }) private val iconScale by setting("Icon Scale", 0.5f, 0.1f..1.0f, 0.1f, { !mcTexture && showIcon }) private val background by setting("Background", true, { !mcTexture }) private val alpha by setting("Alpha", 150, 0..255, 1, { !mcTexture }) - private val containerTexture = ResourceLocation("textures/gui/container/inventory.png") private val lambdaIcon = ResourceLocation("lambda/lambda_icon.png") + private var enderChestContents: MutableList = MutableList(27) { ItemStack(Blocks.AIR) } override val hudWidth: Float = 162.0f override val hudHeight: Float = 54.0f @@ -38,6 +45,7 @@ internal object InventoryViewer : HudElement( runSafe { drawFrame(vertexHelper) drawFrameTexture() + checkEnderChest() drawItems() } } @@ -85,16 +93,42 @@ internal object InventoryViewer : HudElement( } } + + private fun checkEnderChest() { + if (mc.currentScreen is GuiContainer) { + val container = (mc.currentScreen as GuiContainer).inventorySlots + if (container is ContainerChest && container.lowerChestInventory is InventoryBasic) { + val inv = (container.lowerChestInventory as InventoryBasic) + if (inv.name.equals("Ender Chest", true)) { + for (i in 0..26) enderChestContents[i] = container.inventory[i] + } + } + } + } + private fun SafeClientEvent.drawItems() { - for ((index, slot) in player.storageSlots.withIndex()) { - val itemStack = slot.stack - if (itemStack.isEmpty) continue + if (enderChest == SlotType.ENDER_CHEST) { + for ((index, stack) in enderChestContents.withIndex()) { + if (stack.isEmpty) continue + + val slotX = index % 9 * 18 + 1 + val slotY = index / 9 * 18 + 1 + RenderUtils2D.drawItem(stack, slotX, slotY) + } + } else { + for ((index, slot) in player.storageSlots.withIndex()) { + val itemStack = slot.stack + if (itemStack.isEmpty) continue - val slotX = index % 9 * 18 + 1 - val slotY = index / 9 * 18 + 1 + val slotX = index % 9 * 18 + 1 + val slotY = index / 9 * 18 + 1 - RenderUtils2D.drawItem(itemStack, slotX, slotY) + RenderUtils2D.drawItem(itemStack, slotX, slotY) + } } } + private enum class SlotType { + PLAYER, ENDER_CHEST + } } \ No newline at end of file