Skip to content

Commit

Permalink
Implement interfaces of various GUI windows (double chests, anvil, et…
Browse files Browse the repository at this point in the history
…c) and fix NBT/missing packet crashes (#196)

* Implement double chests

* Implement Generic_9x4 and Generic_9x5

* Implement generic_9x1

* Fix generic_9x1's positioning and implement generic_9x2

* Refactor names, fix some formatting.

* Remove forgotten comment

* Fix NBT related crash

* Add missing packet

* Prepare for other interfaces

* Implement anvil ui

* Implement dropper & beacon

* Implement furnace, blast furnace, smoker

* Implement beacon

---------

Co-authored-by: stackotter <stackotter@stackotter.dev>
  • Loading branch information
FloofyPlasma and stackotter committed Jun 5, 2024
1 parent 236994e commit a796dc8
Show file tree
Hide file tree
Showing 6 changed files with 508 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Sources/Core/Sources/Datatypes/NBT/NBTCompound.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extension NBT {
case .end:
break
case .byte:
value = try buffer.readByte()
value = try buffer.readSignedByte()
case .short:
value = try buffer.readSignedShort(endianness: .big)
case .int:
Expand Down
46 changes: 40 additions & 6 deletions Sources/Core/Sources/GUI/GUISprite.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ public enum GUISprite {
case xpBarForeground
case inventory
case craftingTable
/// If positioned directly above ``GUISprite/singleChestBottomHalf`` it forms
case furnace
case blastFurnace
case smoker
case anvil
case dispenser
case beacon

/// If positioned directly above ``GUISprite/genericInventory`` it forms
/// the background for a single chest window. The way the texture is made forces
/// these to be separate sprites.
case singleChestTopHalf
case singleChestBottomHalf
case genericInventory // Inventory for most interfaces, its a part of the sprite
case generic9x1
case generic9x2
case generic9x3
case generic9x4
case generic9x5
case generic9x6

case pinkBossBarBackground
case pinkBossBarForeground
Expand Down Expand Up @@ -81,10 +93,32 @@ public enum GUISprite {
return GUISpriteDescriptor(slice: .inventory, position: [0, 0], size: [176, 166])
case .craftingTable:
return GUISpriteDescriptor(slice: .craftingTable, position: [0, 0], size: [176, 166])
case .singleChestTopHalf:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 71])
case .singleChestBottomHalf:
case .furnace:
return GUISpriteDescriptor(slice: .furnace, position: [0, 0], size: [176, 166])
case .blastFurnace:
return GUISpriteDescriptor(slice: .blastFurnace, position: [0, 0], size: [176, 166])
case .smoker:
return GUISpriteDescriptor(slice: .smoker, position: [0, 0], size: [176, 166])
case .anvil:
return GUISpriteDescriptor(slice: .anvil, position: [0, 0], size: [176, 166])
case .dispenser:
return GUISpriteDescriptor(slice: .dispenser, position: [0, 0], size: [176, 166])
case .beacon:
return GUISpriteDescriptor(slice: .beacon, position: [0,0], size: [229, 218])
case .genericInventory:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 125], size: [176, 97])
case .generic9x1:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 35])
case .generic9x2:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 53])
case .generic9x3:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 71])
case .generic9x4:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 89])
case .generic9x5:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 107])
case .generic9x6:
return GUISpriteDescriptor(slice: .genericContainer, position: [0, 0], size: [176, 222])
case .pinkBossBarBackground:
return GUISpriteDescriptor(slice: .bars, position: [0, 0], size: [182, 5])
case .pinkBossBarForeground:
Expand Down
Loading

0 comments on commit a796dc8

Please sign in to comment.