minecraft-inventory 0.1.20 → 0.1.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minecraft-inventory",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "release": {
@@ -310,7 +310,7 @@ export function InventoryOverlay({
310
310
  lineHeight: 1,
311
311
  }}
312
312
  >
313
- INV 0.1.20
313
+ INV 0.1.21
314
314
  </a>
315
315
  )}
316
316
 
@@ -0,0 +1,46 @@
1
+ import React from 'react'
2
+ import { useScale } from '../../context/ScaleContext'
3
+ import { useInventoryContext } from '../../context/InventoryContext'
4
+
5
+ interface AnvilCostProps {
6
+ properties: Record<string, number>
7
+ backgroundWidth: number
8
+ }
9
+
10
+ export function AnvilCost({ properties, backgroundWidth }: AnvilCostProps) {
11
+ const { scale } = useScale()
12
+ const { windowState } = useInventoryContext()
13
+
14
+ const cost = properties.repairCost ?? 0
15
+ if (cost <= 0) return null
16
+
17
+ const hasResult = windowState?.slots.some((s) => s.index === 2 && s.item !== null) ?? false
18
+ if (!hasResult) return null
19
+
20
+ const tooExpensive = cost >= 40
21
+ const label = tooExpensive ? 'Too Expensive!' : `Enchantment Cost: ${cost}`
22
+ const color = tooExpensive ? '#FF6060' : '#80FF20'
23
+
24
+ return (
25
+ <div
26
+ style={{
27
+ position: 'absolute',
28
+ right: 8 * scale,
29
+ top: 67 * scale,
30
+ height: 12 * scale,
31
+ display: 'flex',
32
+ alignItems: 'center',
33
+ justifyContent: 'flex-end',
34
+ padding: `0 ${2 * scale}px`,
35
+ background: 'rgba(0, 0, 0, 0.3)',
36
+ fontSize: 7 * scale,
37
+ fontFamily: "'Minecraftia', 'Minecraft', monospace",
38
+ color,
39
+ whiteSpace: 'nowrap',
40
+ pointerEvents: 'none',
41
+ }}
42
+ >
43
+ {label}
44
+ </div>
45
+ )
46
+ }
@@ -11,6 +11,7 @@ import { VillagerTradeList } from './VillagerTradeList'
11
11
  import { EnchantmentOptions } from './EnchantmentOptions'
12
12
  import { HotbarExtras } from './HotbarExtras'
13
13
  import { AnvilInput } from './AnvilInput'
14
+ import { AnvilCost } from './AnvilCost'
14
15
  import { EntityDisplay } from './EntityDisplay'
15
16
 
16
17
  interface InventoryWindowProps {
@@ -139,8 +140,9 @@ export function InventoryWindow({
139
140
  />
140
141
  )}
141
142
 
142
- {/* Anvil rename input */}
143
+ {/* Anvil rename input + cost display */}
143
144
  {isAnvil && <AnvilInput x={59} y={20} width={110} height={16} />}
145
+ {isAnvil && <AnvilCost properties={effectiveProperties} backgroundWidth={def.backgroundWidth} />}
144
146
 
145
147
  {/* Hotbar extras: active slot indicator, offhand slot, open-inventory button */}
146
148
  {isHotbar && (