From 4f4a6e7446df08be7f77735fd77a2d28821002f4 Mon Sep 17 00:00:00 2001 From: Falkirks Date: Fri, 24 Oct 2014 17:11:59 -0700 Subject: [PATCH 1/4] Fixes get and set armour --- src/pocketmine/inventory/PlayerInventory.php | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index ec1ee6be7d..8c5cd325e0 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -166,35 +166,35 @@ class PlayerInventory extends BaseInventory{ } public function getHelmet(){ - return $this->getItem($this->getSize() + 3); - } - - public function getChestplate(){ - return $this->getItem($this->getSize() + 2); - } - - public function getLeggings(){ - return $this->getItem($this->getSize() + 1); - } - - public function getBoots(){ return $this->getItem($this->getSize()); } + public function getChestplate(){ + return $this->getItem($this->getSize() + 1); + } + + public function getLeggings(){ + return $this->getItem($this->getSize() + 2); + } + + public function getBoots(){ + return $this->getItem($this->getSize() + 3); + } + public function setHelmet(Item $helmet){ - return $this->setItem($this->getSize() + 3, $helmet); + return $this->setItem($this->getSize(), $helmet); } public function setChestplate(Item $chestplate){ - return $this->setItem($this->getSize() + 2, $chestplate); + return $this->setItem($this->getSize() + 1, $chestplate); } public function setLeggings(Item $leggings){ - return $this->setItem($this->getSize() + 1, $leggings); + return $this->setItem($this->getSize() + 2, $leggings); } public function setBoots(Item $boots){ - return $this->setItem($this->getSize(), $boots); + return $this->setItem($this->getSize() + 3, $boots); } public function setItem($index, Item $item, $source = null){ From 8e7077ff4bbb8452291ecb468ad2d1d3dab8ee3e Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sat, 25 Oct 2014 12:26:57 +0800 Subject: [PATCH 2/4] Update FallingBlock to new Anvil formats, possible fix for #2189 I don't have time to test yet, so I am not sure if it does fix it. --- src/pocketmine/block/Fallable.php | 4 +++- src/pocketmine/entity/FallingBlock.php | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/block/Fallable.php b/src/pocketmine/block/Fallable.php index fdf5126ffc..8faf46acf9 100644 --- a/src/pocketmine/block/Fallable.php +++ b/src/pocketmine/block/Fallable.php @@ -29,6 +29,7 @@ use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\Float; +use pocketmine\nbt\tag\Int; use pocketmine\Player; abstract class Fallable extends Solid{ @@ -60,7 +61,8 @@ abstract class Fallable extends Solid{ new Float("", 0), new Float("", 0) ]), - "Tile" => new Byte("Tile", $this->getID()) + "TileID" => new Int("TileID", $this->getID()), + "Data" => new Byte("Data", $this->getDamage()), ])); $fall->spawnToAll(); diff --git a/src/pocketmine/entity/FallingBlock.php b/src/pocketmine/entity/FallingBlock.php index ac83fe800a..d289552947 100644 --- a/src/pocketmine/entity/FallingBlock.php +++ b/src/pocketmine/entity/FallingBlock.php @@ -28,6 +28,7 @@ use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityRegainHealthEvent; use pocketmine\item\Item; use pocketmine\nbt\tag\Byte; +use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\String; use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\SetEntityMotionPacket; @@ -44,13 +45,18 @@ class FallingBlock extends Entity{ protected $gravity = 0.04; protected $drag = 0.02; protected $blockId = 0; + protected $damage; public $canCollide = false; protected function initEntity(){ $this->namedtag->id = new String("id", "FallingSand"); - if(isset($this->namedtag->Tile)){ + if(isset($this->namedtag->TileID)){ + $this->blockId = $this->namedtag["TileID"]; + } + elseif(isset($this->namedtag->Tile)){ $this->blockId = $this->namedtag["Tile"]; + $this->namedtag["TileID"] = $this->blockId; } if($this->blockId === 0){ @@ -106,9 +112,9 @@ class FallingBlock extends Entity{ $this->kill(); $block = $this->level->getBlock($pos); if(!$block->isFullBlock){ - $this->getLevel()->dropItem($this, Item::get($this->getBlock(), 0, 1)); + $this->getLevel()->dropItem($this, Item::get($this->getBlock(), $this->getDamage(), 1)); }else{ - $this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), 0))); + $this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage()))); if(!$ev->isCancelled()){ $this->getLevel()->setBlock($pos, $ev->getTo(), true); } @@ -125,9 +131,13 @@ class FallingBlock extends Entity{ public function getBlock(){ return $this->blockId; } + public function getDamage(){ + return $this->damage; + } public function saveNBT(){ - $this->namedtag->Tile = new Byte("Tile", $this->blockId); + $this->namedtag->TileID = new Int("TileID", $this->blockId); + $this->namedtag->Data = new Byte("Data", $this->damage); } public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC){ From ee4f416d93b842934a56b77e9317bc58b565a17e Mon Sep 17 00:00:00 2001 From: PEMapModder Date: Sat, 25 Oct 2014 18:15:47 +0800 Subject: [PATCH 3/4] Fix FallingBlock.php --- src/pocketmine/entity/FallingBlock.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/entity/FallingBlock.php b/src/pocketmine/entity/FallingBlock.php index d289552947..43fea4900a 100644 --- a/src/pocketmine/entity/FallingBlock.php +++ b/src/pocketmine/entity/FallingBlock.php @@ -56,7 +56,7 @@ class FallingBlock extends Entity{ } elseif(isset($this->namedtag->Tile)){ $this->blockId = $this->namedtag["Tile"]; - $this->namedtag["TileID"] = $this->blockId; + $this->namedtag["TileID"] = new Int("TileID", $this->blockId); } if($this->blockId === 0){ @@ -166,4 +166,4 @@ class FallingBlock extends Entity{ parent::spawnTo($player); } -} \ No newline at end of file +} From df81b365e56ecf5ea7b598bd1c8d777876d15c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=82=A4=EB=A6=AC=ED=86=A0?= Date: Sun, 26 Oct 2014 22:21:21 +0900 Subject: [PATCH 4/4] Update BaseInventory.php --- src/pocketmine/inventory/BaseInventory.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index e9e6dd7e33..6353e2ca31 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -126,6 +126,7 @@ abstract class BaseInventory implements Inventory{ return false; }elseif($item->getID() === 0 or $item->getCount() <= 0){ $this->clear($index, $source); + return true; } $holder = $this->getHolder(); @@ -426,4 +427,4 @@ abstract class BaseInventory implements Inventory{ return $this->type; } -} \ No newline at end of file +}