Skip to content

Commit

Permalink
Merge pull request #981 from Hydreon/no_send_slot_to_holder
Browse files Browse the repository at this point in the history
No send slot to holder
  • Loading branch information
vchibikov authored Sep 29, 2020
2 parents a1b6d42 + c0cc3ad commit 14ccfc7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/pocketmine/inventory/PlayerInventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,16 @@ public function onSlotChange($index, $before, $sendPacket = true){
return;
}

parent::onSlotChange($index, $before, $sendPacket);

if ($sendPacket) {
if ($sendPacket == -1) {
$viewers = $this->getViewers();
unset($viewers[spl_object_hash($this->holder)]);
parent::sendSlot($index, $viewers);
} else {
parent::onSlotChange($index, $before, $sendPacket);
}
}

if ($index >= $this->getSize() && $sendPacket === true) {
$this->sendArmorSlot($index, $this->getHolder()->getViewers());
Expand Down Expand Up @@ -243,7 +252,7 @@ public function setItem($index, Item $item, $sendPacket = true){
switch ($index) {
case self::CURSOR_INDEX:
$this->cursor = clone $item;
if ($sendPacket) {
if ($sendPacket === true) {
$this->sendCursor();
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/inventory/SimpleTransactionGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public function execute() {
}

foreach ($this->transactions as $transaction) {
$transaction->getInventory()->setItem($transaction->getSlot(), $transaction->getTargetItem());
$transaction->getInventory()->setItem($transaction->getSlot(), $transaction->getTargetItem(), -1);
if ($transaction->isNeedInventoryUpdate()) {
$this->sendInventories();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public function isUpdateEnchantSlotTransaction() {
* @return BaseTransaction
*/
public function convertToTransaction($player) {
$hack = false;
if ($this->action == self::ACTION_CRAFT_USE) {
$this->inventoryId = -1;
$this->slot = 0;
$hack = true;
}
switch ($this->inventoryId) {
case Protocol120::CONTAINER_ID_INVENTORY:
$inventory = $player->getInventory();
Expand Down Expand Up @@ -140,7 +146,7 @@ public function convertToTransaction($player) {
case self::ACTION_CRAFT_USE:
if ($this->slot == 0) {
$item = $inventory->getItem(PlayerInventory::CRAFT_INDEX_0);
if (!$this->newItem->equals($item) || $item->getCount() < $this->newItem->getCount()) {
if (!$this->newItem->equals($item) || $item->getCount() < $this->newItem->getCount() || $hack) {
if (!$inventory->isQuickCraftEnabled()) {
$inventory->setQuickCraftMode(true);
}
Expand Down

0 comments on commit 14ccfc7

Please sign in to comment.