minecraft-inventory 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/package.json +1 -1
- package/src/bundledTexturesConfig.ts +126 -0
- package/src/cache/blockRenderer.ts +103 -0
- package/src/cache/textureCache.ts +10 -0
- package/src/components/InventoryOverlay/InventoryOverlay.tsx +1 -1
- package/src/components/InventoryWindow/InventoryBackground.tsx +69 -82
- package/src/components/ItemCanvas/ItemCanvas.tsx +103 -17
- package/src/components/JEI/JEI.module.css +2 -0
- package/src/components/JEI/JEI.tsx +2 -3
- package/src/components/Notes/Notes.tsx +76 -45
- package/src/components/Slot/Slot.tsx +6 -0
- package/src/components/Text/MessageFormattedString.tsx +1 -0
- package/src/components/Tooltip/Tooltip.tsx +1 -2
- package/src/connector/demo.ts +65 -0
- package/src/connector/mineflayer.ts +18 -3
- package/src/context/InventoryContext.tsx +34 -17
- package/src/generated/localTextures.ts +66 -51
- package/src/index.tsx +19 -1
- package/src/registry/index.ts +30 -1
- package/src/registry/inventories.ts +19 -16
- package/src/types.ts +38 -0
|
@@ -127,19 +127,20 @@ export const inventoryDefinitions = makeInventoryDefinitions({
|
|
|
127
127
|
|
|
128
128
|
// generic_9x1..9x6 all use generic_54.png (the 6-row chest texture, 176×222).
|
|
129
129
|
// InventoryBackground canvas-stitches rows < 6: takes the top N rows from the source
|
|
130
|
-
// then the player-inventory section
|
|
131
|
-
//
|
|
132
|
-
//
|
|
130
|
+
// (y=0..topH-1, where topH = N*18+17) then the player-inventory section starting at
|
|
131
|
+
// y=SRC_PLAYER_Y=125 and composites them.
|
|
132
|
+
// Output height formula: N*18+17 + (222-125) = N*18+17+97 = N*18+114.
|
|
133
|
+
// Slot formula: container at y=18, player at y = N*18+30 (13px frame into player section).
|
|
133
134
|
generic_9x1: {
|
|
134
135
|
name: 'generic_9x1',
|
|
135
136
|
title: 'Container',
|
|
136
137
|
backgroundTexture: '1.21.11/textures/gui/container/generic_54.png',
|
|
137
138
|
backgroundWidth: 176,
|
|
138
|
-
backgroundHeight:
|
|
139
|
+
backgroundHeight: 132, // 1*18 + 114
|
|
139
140
|
containerRows: 1,
|
|
140
141
|
slots: [
|
|
141
142
|
...gridSlots(9, 1, 8, 18, 'container'),
|
|
142
|
-
...playerInv(
|
|
143
|
+
...playerInv(50), // 1*18 + 30 + 2px offset below
|
|
143
144
|
],
|
|
144
145
|
},
|
|
145
146
|
|
|
@@ -148,11 +149,11 @@ export const inventoryDefinitions = makeInventoryDefinitions({
|
|
|
148
149
|
title: 'Container',
|
|
149
150
|
backgroundTexture: '1.21.11/textures/gui/container/generic_54.png',
|
|
150
151
|
backgroundWidth: 176,
|
|
151
|
-
backgroundHeight:
|
|
152
|
+
backgroundHeight: 150, // 2*18 + 114
|
|
152
153
|
containerRows: 2,
|
|
153
154
|
slots: [
|
|
154
155
|
...gridSlots(9, 2, 8, 18, 'container'),
|
|
155
|
-
...playerInv(
|
|
156
|
+
...playerInv(68), // 2*18 + 30 + 2px offset below
|
|
156
157
|
],
|
|
157
158
|
},
|
|
158
159
|
|
|
@@ -161,12 +162,12 @@ export const inventoryDefinitions = makeInventoryDefinitions({
|
|
|
161
162
|
title: 'Container',
|
|
162
163
|
backgroundTexture: '1.21.11/textures/gui/container/generic_54.png',
|
|
163
164
|
backgroundWidth: 176,
|
|
164
|
-
backgroundHeight:
|
|
165
|
+
backgroundHeight: 168, // 3*18 + 114
|
|
165
166
|
containerRows: 3,
|
|
166
|
-
playerInventoryOffset: { x: 8, y:
|
|
167
|
+
playerInventoryOffset: { x: 8, y: 82 },
|
|
167
168
|
slots: [
|
|
168
169
|
...gridSlots(9, 3, 8, 18, 'container'),
|
|
169
|
-
...playerInv(
|
|
170
|
+
...playerInv(86), // 3*18 + 30 + 2px offset below
|
|
170
171
|
],
|
|
171
172
|
},
|
|
172
173
|
|
|
@@ -175,11 +176,11 @@ export const inventoryDefinitions = makeInventoryDefinitions({
|
|
|
175
176
|
title: 'Container',
|
|
176
177
|
backgroundTexture: '1.21.11/textures/gui/container/generic_54.png',
|
|
177
178
|
backgroundWidth: 176,
|
|
178
|
-
backgroundHeight:
|
|
179
|
+
backgroundHeight: 186, // 4*18 + 114
|
|
179
180
|
containerRows: 4,
|
|
180
181
|
slots: [
|
|
181
182
|
...gridSlots(9, 4, 8, 18, 'container'),
|
|
182
|
-
...playerInv(
|
|
183
|
+
...playerInv(104), // 4*18 + 30 + 2px offset below
|
|
183
184
|
],
|
|
184
185
|
},
|
|
185
186
|
|
|
@@ -188,11 +189,11 @@ export const inventoryDefinitions = makeInventoryDefinitions({
|
|
|
188
189
|
title: 'Container',
|
|
189
190
|
backgroundTexture: '1.21.11/textures/gui/container/generic_54.png',
|
|
190
191
|
backgroundWidth: 176,
|
|
191
|
-
backgroundHeight:
|
|
192
|
+
backgroundHeight: 204, // 5*18 + 114
|
|
192
193
|
containerRows: 5,
|
|
193
194
|
slots: [
|
|
194
195
|
...gridSlots(9, 5, 8, 18, 'container'),
|
|
195
|
-
...playerInv(
|
|
196
|
+
...playerInv(122), // 5*18 + 30 + 2px offset below
|
|
196
197
|
],
|
|
197
198
|
},
|
|
198
199
|
|
|
@@ -201,8 +202,9 @@ export const inventoryDefinitions = makeInventoryDefinitions({
|
|
|
201
202
|
title: 'Container',
|
|
202
203
|
backgroundTexture: '1.21.11/textures/gui/container/generic_54.png',
|
|
203
204
|
backgroundWidth: 176,
|
|
204
|
-
backgroundHeight: 222, // full 6-row texture, no stitching needed
|
|
205
|
+
backgroundHeight: 222, // full 6-row texture, no stitching needed (N*18+114 = 222)
|
|
205
206
|
playerInventoryOffset: { x: 8, y: 140 },
|
|
207
|
+
containerRows: 6,
|
|
206
208
|
slots: [
|
|
207
209
|
...gridSlots(9, 6, 8, 18, 'container'),
|
|
208
210
|
...playerInv(140), // matches large_chest
|
|
@@ -215,7 +217,8 @@ export const inventoryDefinitions = makeInventoryDefinitions({
|
|
|
215
217
|
backgroundTexture: '1.21.11/textures/gui/container/generic_54.png',
|
|
216
218
|
backgroundWidth: 176,
|
|
217
219
|
backgroundHeight: 222,
|
|
218
|
-
|
|
220
|
+
containerRows: 6,
|
|
221
|
+
playerInventoryOffset: { x: 8, y: 138 },
|
|
219
222
|
slots: [
|
|
220
223
|
...gridSlots(9, 6, 8, 18, 'container'),
|
|
221
224
|
...playerInv(140),
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/** Slice rect [x, y, width, height] in source texture pixels. */
|
|
2
|
+
export type TextureSlice = [x:number, y:number, width:number, height:number]
|
|
3
|
+
|
|
4
|
+
/** Block face slice for isometric block rendering. */
|
|
5
|
+
export interface BlockFaceSlice {
|
|
6
|
+
slice: TextureSlice
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Block-style render config. When set, ItemCanvas uses an aux canvas to composite
|
|
11
|
+
* top/left/right faces into an isometric icon instead of a single texture.
|
|
12
|
+
* Useful for blocks in mineflayer connector where block texture atlas faces differ.
|
|
13
|
+
*/
|
|
14
|
+
export interface BlockTextureRender {
|
|
15
|
+
/** Source texture URL or preloaded HTMLImageElement. */
|
|
16
|
+
source: string | HTMLImageElement
|
|
17
|
+
top: BlockFaceSlice
|
|
18
|
+
left: BlockFaceSlice
|
|
19
|
+
right: BlockFaceSlice
|
|
20
|
+
}
|
|
21
|
+
|
|
1
22
|
export interface ItemStack {
|
|
2
23
|
type: number
|
|
3
24
|
count: number
|
|
@@ -19,6 +40,23 @@ export interface ItemStack {
|
|
|
19
40
|
* Example: `"item/dye_black"` or `"entity/spider/spider"`
|
|
20
41
|
*/
|
|
21
42
|
textureKey?: string
|
|
43
|
+
/**
|
|
44
|
+
* Direct texture override. When set, bypasses getItemTextureUrl.
|
|
45
|
+
* - `string`: URL (data URL or http) used as img src.
|
|
46
|
+
* - `HTMLImageElement`: preloaded image, drawn directly.
|
|
47
|
+
*/
|
|
48
|
+
texture?: string | HTMLImageElement
|
|
49
|
+
/**
|
|
50
|
+
* Block-style isometric render. When set, ItemCanvas uses a canvas pool to composite
|
|
51
|
+
* top/left/right face slices into the icon. Use in mineflayer itemMapper for blocks.
|
|
52
|
+
*/
|
|
53
|
+
blockTexture?: BlockTextureRender
|
|
54
|
+
/**
|
|
55
|
+
* Arbitrary debug identifier exposed as a `data-debug` attribute on the slot element.
|
|
56
|
+
* The mineflayer connector sets this to `"<type>:<metadata>"` by default, making it easy
|
|
57
|
+
* to inspect raw item IDs in browser DevTools without touching React internals.
|
|
58
|
+
*/
|
|
59
|
+
debugKey?: string
|
|
22
60
|
}
|
|
23
61
|
|
|
24
62
|
export interface SlotState {
|