up3
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
Build and deploy / Build (push) Has been cancelled
Build and deploy / Update Contributors (push) Has been cancelled
Build and deploy / Deploy (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/df-mc/dragonfly/server/world"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol"
|
||||
"github.com/sandertv/gophertunnel/minecraft/protocol/packet"
|
||||
)
|
||||
|
||||
// MobEquipmentHandler handles the MobEquipment packet.
|
||||
type MobEquipmentHandler struct{}
|
||||
|
||||
// Handle ...
|
||||
func (*MobEquipmentHandler) Handle(p packet.Packet, s *Session, tx *world.Tx, c Controllable) error {
|
||||
pk := p.(*packet.MobEquipment)
|
||||
|
||||
if pk.EntityRuntimeID != selfEntityRuntimeID {
|
||||
return errSelfRuntimeID
|
||||
}
|
||||
switch pk.WindowID {
|
||||
case protocol.WindowIDOffHand:
|
||||
// This window ID is expected, but we don't handle it.
|
||||
return nil
|
||||
case protocol.WindowIDInventory:
|
||||
return s.VerifyAndSetHeldSlot(int(pk.InventorySlot), stackToItem(s.br, pk.NewItem.Stack), c)
|
||||
default:
|
||||
return fmt.Errorf("only main inventory should be involved in slot change, got window ID %v", pk.WindowID)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user