Something
This commit is contained in:
5
main.go
5
main.go
@@ -380,7 +380,7 @@ func handleRequest(conn net.Conn) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Handle block entity query logic here
|
// Handle block entity query logic here
|
||||||
player.queryBlockEntityTag(transactionID, position)
|
//player.queryBlockEntityTag(transactionID, position)
|
||||||
|
|
||||||
case 0x02: // Change Difficulty
|
case 0x02: // Change Difficulty
|
||||||
difficulty, err := packetData.ReadByte()
|
difficulty, err := packetData.ReadByte()
|
||||||
@@ -403,7 +403,8 @@ func handleRequest(conn net.Conn) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
// Acknowledge message logic here
|
// Acknowledge message logic here
|
||||||
player.acknowledgeMessage(messageCount)
|
messageCount = messageCount
|
||||||
|
//player.acknowledgeMessage(messageCount)
|
||||||
|
|
||||||
case 0x04, 0x05: // Chat Command & Signed Chat Command
|
case 0x04, 0x05: // Chat Command & Signed Chat Command
|
||||||
command, err := receiveString(packetData)
|
command, err := receiveString(packetData)
|
||||||
|
30
structs.go
30
structs.go
@@ -503,6 +503,36 @@ type ItemStack struct {
|
|||||||
MaxCount int32
|
MaxCount int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteToBuffer serializes the ItemStack to a bytes.Buffer
|
||||||
|
func (i *ItemStack) WriteToBuffer(buf *bytes.Buffer) error {
|
||||||
|
// Add Item Count as VarInt
|
||||||
|
addVarint(buf, i.Count)
|
||||||
|
|
||||||
|
// Add optional fields only if Count > 0
|
||||||
|
if i.Count > 0 {
|
||||||
|
// Add ItemID as VarInt
|
||||||
|
addVarint(buf, i.ItemID)
|
||||||
|
|
||||||
|
// Add Number of components to add as VarInt
|
||||||
|
addVarint(buf, int32(len(i.ComponentsToAdd)))
|
||||||
|
for k, v := range i.ComponentsToAdd {
|
||||||
|
addVarint(buf, k)
|
||||||
|
// Customize based on an actual type of 'v'
|
||||||
|
if strVal, ok := v.(string); ok {
|
||||||
|
addVarint(buf, int32(len(strVal)))
|
||||||
|
addString(buf, strVal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Number of components to remove as VarInt
|
||||||
|
addVarint(buf, int32(len(i.ComponentsToRemove)))
|
||||||
|
for _, v := range i.ComponentsToRemove {
|
||||||
|
addVarint(buf, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (slot *ItemStack) IsEmpty() bool {
|
func (slot *ItemStack) IsEmpty() bool {
|
||||||
return slot.Count == 0
|
return slot.Count == 0
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user