Rough OffHand implementation

this doesn't do stuff like taking arrows from offhand yet.
This commit is contained in:
Dylan K. Taylor
2021-05-05 14:46:51 +01:00
parent e8cb49f7ae
commit 652de2632a
9 changed files with 101 additions and 11 deletions

View File

@@ -963,14 +963,18 @@ class NetworkSession{
/**
* TODO: expand this to more than just humans
* TODO: offhand
*/
public function onMobEquipmentChange(Human $mob) : void{
public function onMobMainHandItemChange(Human $mob) : void{
//TODO: we could send zero for slot here because remote players don't need to know which slot was selected
$inv = $mob->getInventory();
$this->sendDataPacket(MobEquipmentPacket::create($mob->getId(), ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($inv->getItemInHand())), $inv->getHeldItemIndex(), ContainerIds::INVENTORY));
}
public function onMobOffHandItemChange(Human $mob) : void{
$inv = $mob->getOffHandInventory();
$this->sendDataPacket(MobEquipmentPacket::create($mob->getId(), ItemStackWrapper::legacy(TypeConverter::getInstance()->coreItemStackToNet($inv->getItem(0))), 0, ContainerIds::OFFHAND));
}
public function onMobArmorChange(Living $mob) : void{
$inv = $mob->getArmorInventory();
$converter = TypeConverter::getInstance();