@@ -10,9 +10,15 @@ import com.lambda.client.util.graphics.VertexHelper
10
10
import com.lambda.client.util.items.storageSlots
11
11
import com.lambda.client.util.math.Vec2d
12
12
import com.lambda.client.util.threads.runSafe
13
+ import net.minecraft.client.gui.inventory.GuiContainer
13
14
import net.minecraft.client.renderer.GlStateManager
14
15
import net.minecraft.client.renderer.Tessellator
15
16
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
17
+ import net.minecraft.init.Blocks
18
+ import net.minecraft.inventory.Container
19
+ import net.minecraft.inventory.ContainerChest
20
+ import net.minecraft.inventory.InventoryBasic
21
+ import net.minecraft.item.ItemStack
16
22
import net.minecraft.util.ResourceLocation
17
23
import org.lwjgl.opengl.GL11.*
18
24
@@ -21,14 +27,15 @@ internal object InventoryViewer : HudElement(
21
27
category = Category .PLAYER ,
22
28
description = " Items in Inventory"
23
29
) {
30
+ private val enderChest by setting(" Inventory" , SlotType .PLAYER )
24
31
private val mcTexture by setting(" Minecraft Texture" , false )
25
32
private val showIcon by setting(" Show Icon" , false , { ! mcTexture })
26
33
private val iconScale by setting(" Icon Scale" , 0.5f , 0.1f .. 1.0f , 0.1f , { ! mcTexture && showIcon })
27
34
private val background by setting(" Background" , true , { ! mcTexture })
28
35
private val alpha by setting(" Alpha" , 150 , 0 .. 255 , 1 , { ! mcTexture })
29
-
30
36
private val containerTexture = ResourceLocation (" textures/gui/container/inventory.png" )
31
37
private val lambdaIcon = ResourceLocation (" lambda/lambda_icon.png" )
38
+ private var enderChestContents: MutableList <ItemStack > = MutableList (27 ) { ItemStack (Blocks .AIR ) }
32
39
33
40
override val hudWidth: Float = 162.0f
34
41
override val hudHeight: Float = 54.0f
@@ -38,6 +45,7 @@ internal object InventoryViewer : HudElement(
38
45
runSafe {
39
46
drawFrame(vertexHelper)
40
47
drawFrameTexture()
48
+ checkEnderChest()
41
49
drawItems()
42
50
}
43
51
}
@@ -85,16 +93,42 @@ internal object InventoryViewer : HudElement(
85
93
}
86
94
}
87
95
96
+
97
+ private fun checkEnderChest () {
98
+ if (mc.currentScreen is GuiContainer ) {
99
+ val container = (mc.currentScreen as GuiContainer ).inventorySlots
100
+ if (container is ContainerChest && container.lowerChestInventory is InventoryBasic ) {
101
+ val inv = (container.lowerChestInventory as InventoryBasic )
102
+ if (inv .name.equals(" Ender Chest" , true )) {
103
+ for (i in 0 .. 26 ) enderChestContents[i] = container.inventory[i]
104
+ }
105
+ }
106
+ }
107
+ }
108
+
88
109
private fun SafeClientEvent.drawItems () {
89
- for ((index, slot) in player.storageSlots.withIndex()) {
90
- val itemStack = slot.stack
91
- if (itemStack.isEmpty) continue
110
+ if (enderChest == SlotType .ENDER_CHEST ) {
111
+ for ((index, stack) in enderChestContents.withIndex()) {
112
+ if (stack.isEmpty) continue
113
+
114
+ val slotX = index % 9 * 18 + 1
115
+ val slotY = index / 9 * 18 + 1
116
+ RenderUtils2D .drawItem(stack, slotX, slotY)
117
+ }
118
+ } else {
119
+ for ((index, slot) in player.storageSlots.withIndex()) {
120
+ val itemStack = slot.stack
121
+ if (itemStack.isEmpty) continue
92
122
93
- val slotX = index % 9 * 18 + 1
94
- val slotY = index / 9 * 18 + 1
123
+ val slotX = index % 9 * 18 + 1
124
+ val slotY = index / 9 * 18 + 1
95
125
96
- RenderUtils2D .drawItem(itemStack, slotX, slotY)
126
+ RenderUtils2D .drawItem(itemStack, slotX, slotY)
127
+ }
97
128
}
98
129
}
99
130
131
+ private enum class SlotType {
132
+ PLAYER , ENDER_CHEST
133
+ }
100
134
}
0 commit comments