flying-squid/lib/playerPlugins/inventory.js
Romain Beaumont 76e5d006fc fix inventory
2015-10-09 18:07:33 +02:00

58 lines
1.6 KiB
JavaScript

module.exports=inject;
function inject(serv, player)
{
player.heldItemSlot=0;
player.heldItem=0;
player.inventory=new Array(44);
player._client.on("held_item_slot", function (packet) {
player.heldItemSlot = packet.slotId;
if(player.inventory[36+heldItemSlot]===undefined){
player.inventory[36+heldItemSlot]={
blockId:-1
};
}
player.heldItem = player.inventory[36+heldItemSlot];
player._writeOthers("entity_equipment",{
entityId:player.entity.id,
slot:0,
item:heldItem
});
});
player._client.on("set_creative_slot", function (packet) {
player.inventory[packet.slot]=packet.item;
if (packet.slot==36)
player._writeOthers("entity_equipment",{
entityId:player.entity.id,
slot:0,
item:packet.item
});
if (packet.slot==5)
player._writeOthers("entity_equipment",{
entityId:player.entity.id,
slot:4,
item:packet.item
});
if (packet.slot==6)
player._writeOthers("entity_equipment",{
entityId:player.entity.id,
slot:3,
item:packet.item
});
if (packet.slot==7)
player._writeOthers("entity_equipment",{
entityId:player.entity.id,
slot:2,
item:packet.item
});
if (packet.slot==8)
player._writeOthers("entity_equipment",{
entityId:player.entity.id,
slot:1,
item:packet.item
});
});
}