Skip to content

Commit

Permalink
Implement Generic_9x4 and Generic_9x5
Browse files Browse the repository at this point in the history
  • Loading branch information
FloofyPlasma committed May 28, 2024
1 parent 738c5a1 commit 3a66108
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 3 deletions.
9 changes: 7 additions & 2 deletions Sources/Core/Sources/GUI/GUISprite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum GUISprite {
case singleChestTopHalf
case singleChestBottomHalf
case doubleChest // No top/bottom half since it just uses the full image

case generic9x4
case generic9x5
/// The descriptor for the sprite.
public var descriptor: GUISpriteDescriptor {
switch self {
Expand Down Expand Up @@ -63,7 +64,11 @@ public enum GUISprite {
case .singleChestBottomHalf:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 125], size: [176, 97])
case .doubleChest:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 222]) // Use the entire generic container image
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 222])
case .generic9x4:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 89])
case .generic9x5:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 107])
}
}
}
65 changes: 64 additions & 1 deletion Sources/Core/Sources/GUI/WindowType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,76 @@ public struct WindowType {
]
)

// Generic window types
public static let generic9x4 = WindowType(
id: .vanilla(3),
identifier: Identifier(namespace: "minecraft", name: "generic_9x4"),
background: GUIElement.list(spacing: 0) {
GUIElement.sprite(.generic9x4)
GUIElement.sprite(.singleChestBottomHalf) // Use the inventory section of the bottom half of the chest, wouldn't a more generic name for it be better?
},
slotCount: 72,
areas: [
WindowArea(
startIndex: 0,
width: 9,
height: 4,
position: Vec2i(8, 18)
),
WindowArea(
startIndex: 36,
width: 9,
height: 3,
position: Vec2i(8, 104)
),
WindowArea(
startIndex: 63,
width: 9,
height: 1,
position: Vec2i(8, 162)
)
]
)

public static let generic9x5 = WindowType(
id: .vanilla(4),
identifier: Identifier(namespace: "minecraft", name:"generic_9x5"),
background: GUIElement.list(spacing: 0) {
GUIElement.sprite(.generic9x5)
GUIElement.sprite(.singleChestBottomHalf) // Same reasoning as 9x4
},
slotCount: 81,
areas: [
WindowArea(
startIndex: 0,
width: 9,
height: 5,
position: Vec2i(8, 18)
),
WindowArea(
startIndex: 45,
width: 9,
height: 3,
position: Vec2i(8, 122)
),
WindowArea(
startIndex: 72,
width: 9,
height: 1,
position: Vec2i(8, 180)
)
]
)

/// The window types understood by vanilla.
public static let types = [Id: Self](
values: [
inventory,
craftingTable,
chest,
doubleChest
doubleChest,
generic9x4,
generic9x5
],
keyedBy: \.id
)
Expand Down

0 comments on commit 3a66108

Please sign in to comment.