Merge branch 'release/3.5'

This commit is contained in:
Dylan K. Taylor 2018-12-13 10:54:30 +00:00
commit 125cc28aa0

View File

@ -48,8 +48,8 @@ class NetworkInventoryAction{
*
* Expect these to change in the future.
*/
public const SOURCE_TYPE_CRAFTING_USELESS_MAGIC_NUMBER = -2;
public const SOURCE_TYPE_CRAFTING_ADD_INGREDIENT = -2;
public const SOURCE_TYPE_CRAFTING_REMOVE_INGREDIENT = -3;
public const SOURCE_TYPE_CRAFTING_RESULT = -4;
public const SOURCE_TYPE_CRAFTING_USE_INGREDIENT = -5;
@ -109,11 +109,6 @@ class NetworkInventoryAction{
case self::SOURCE_CREATIVE:
break;
case self::SOURCE_CRAFTING_GRID:
$dummy = $packet->getVarInt();
if($dummy !== self::SOURCE_TYPE_CRAFTING_USELESS_MAGIC_NUMBER){
throw new \UnexpectedValueException("Useless magic number for crafting-grid type was $dummy, expected " . self::SOURCE_TYPE_CRAFTING_USELESS_MAGIC_NUMBER);
}
break;
case self::SOURCE_TODO:
$this->windowId = $packet->getVarInt();
switch($this->windowId){
@ -152,8 +147,6 @@ class NetworkInventoryAction{
case self::SOURCE_CREATIVE:
break;
case self::SOURCE_CRAFTING_GRID:
$packet->putVarInt(self::SOURCE_TYPE_CRAFTING_USELESS_MAGIC_NUMBER);
break;
case self::SOURCE_TODO:
$packet->putVarInt($this->windowId);
break;
@ -201,24 +194,16 @@ class NetworkInventoryAction{
return new CreativeInventoryAction($this->oldItem, $this->newItem, $type);
case self::SOURCE_CRAFTING_GRID:
return new SlotChangeAction($player->getCraftingGrid(), $this->inventorySlot, $this->oldItem, $this->newItem);
case self::SOURCE_TODO:
//These types need special handling.
switch($this->windowId){
case self::SOURCE_TYPE_CRAFTING_ADD_INGREDIENT:
case self::SOURCE_TYPE_CRAFTING_REMOVE_INGREDIENT:
case self::SOURCE_TYPE_CONTAINER_DROP_CONTENTS: //TODO: this type applies to all fake windows, not just crafting
return new SlotChangeAction($player->getCraftingGrid(), $this->inventorySlot, $this->oldItem, $this->newItem);
case self::SOURCE_TYPE_CRAFTING_RESULT:
case self::SOURCE_TYPE_CRAFTING_USE_INGREDIENT:
return null;
case self::SOURCE_TYPE_CONTAINER_DROP_CONTENTS:
//TODO: this type applies to all fake windows, not just crafting
$window = $player->getCraftingGrid();
//DROP_CONTENTS doesn't bother telling us what slot the item is in, so we find it ourselves
$inventorySlot = $window->first($this->oldItem, true);
if($inventorySlot === -1){
throw new \InvalidStateException("Fake container " . get_class($window) . " for " . $player->getName() . " does not contain $this->oldItem");
}
return new SlotChangeAction($window, $inventorySlot, $this->oldItem, $this->newItem);
}
//TODO: more stuff