-
Notifications
You must be signed in to change notification settings - Fork 76
Code Updates for PMMP 3.19.0, fix for #448 #449
Changes from 1 commit
135688a
4c78505
5bd7feb
0e2f82b
0f54485
bea1525
3c30e44
a5b4e18
e339508
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,6 @@ | |
use pocketmine\item\IronHelmet; | ||
use pocketmine\item\IronLeggings; | ||
use pocketmine\item\Item; | ||
use pocketmine\item\ItemIds; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the use of ItemIds to Item is not required to be compatible with 3.19.0. Please revert all related changes and open a separate PR to handle this. |
||
use pocketmine\item\LeatherBoots; | ||
use pocketmine\item\LeatherCap; | ||
use pocketmine\item\LeatherPants; | ||
|
@@ -54,6 +53,7 @@ | |
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket; | ||
use pocketmine\network\mcpe\protocol\MobEquipmentPacket; | ||
use pocketmine\network\mcpe\protocol\TakeItemActorPacket; | ||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; | ||
use pocketmine\Player; | ||
use pocketmine\Server; | ||
use revivalpmmp\pureentities\config\mobequipment\EntityConfig; | ||
|
@@ -337,19 +337,19 @@ public function addLoot(array $existingDrops){ | |
// see: http://minecraft.gamepedia.com/Sword (section: mobs) | ||
if(mt_rand(0, 100) <= 9){ | ||
// drop all equipment | ||
if($this->mainHand !== null && $this->mainHand->getId() !== ItemIds::AIR){ | ||
if($this->mainHand !== null && $this->mainHand->getId() !== Item::AIR){ | ||
array_push($existingDrops, $this->mainHand); | ||
} | ||
if($this->helmet !== null && $this->helmet->getId() !== ItemIds::AIR){ | ||
if($this->helmet !== null && $this->helmet->getId() !== Item::AIR){ | ||
array_push($existingDrops, $this->helmet); | ||
} | ||
if($this->boots !== null && $this->boots->getId() !== ItemIds::AIR){ | ||
if($this->boots !== null && $this->boots->getId() !== Item::AIR){ | ||
array_push($existingDrops, $this->boots); | ||
} | ||
if($this->chestplate !== null && $this->chestplate->getId() !== ItemIds::AIR){ | ||
if($this->chestplate !== null && $this->chestplate->getId() !== Item::AIR){ | ||
array_push($existingDrops, $this->chestplate); | ||
} | ||
if($this->leggings !== null && $this->leggings->getId() !== ItemIds::AIR){ | ||
if($this->leggings !== null && $this->leggings->getId() !== Item::AIR){ | ||
array_push($existingDrops, $this->leggings); | ||
} | ||
} | ||
|
@@ -437,7 +437,7 @@ private function getWeaponDamage() : int{ | |
private function getChestplateArmorPoints() : int{ | ||
$armor = 0; | ||
$item = $this->getChestplate(); | ||
if($item !== null && $item->getId() !== ItemIds::AIR){ | ||
if($item !== null && $item->getId() !== Item::AIR){ | ||
if($item instanceof LeatherTunic){ | ||
$armor = 3; | ||
}else if($item instanceof GoldChestplate){ | ||
|
@@ -461,7 +461,7 @@ private function getChestplateArmorPoints() : int{ | |
private function getHelmetArmorPoints() : int{ | ||
$armor = 0; | ||
$item = $this->getHelmet(); | ||
if($item !== null && $item->getId() !== ItemIds::AIR){ | ||
if($item !== null && $item->getId() !== Item::AIR){ | ||
if($item instanceof LeatherCap){ | ||
$armor = 1; | ||
}else if($item instanceof GoldHelmet){ | ||
|
@@ -485,7 +485,7 @@ private function getHelmetArmorPoints() : int{ | |
private function getBootsArmorPoints() : int{ | ||
$armor = 0; | ||
$item = $this->getBoots(); | ||
if($item !== null && $item->getId() !== ItemIds::AIR){ | ||
if($item !== null && $item->getId() !== Item::AIR){ | ||
if($item instanceof LeatherBoots){ | ||
$armor = 1; | ||
}else if($item instanceof GoldBoots){ | ||
|
@@ -509,7 +509,7 @@ private function getBootsArmorPoints() : int{ | |
private function getLeggingsArmorPoints() : int{ | ||
$armor = 0; | ||
$item = $this->getBoots(); | ||
if($item !== null && $item->getId() !== ItemIds::AIR){ | ||
if($item !== null && $item->getId() !== Item::AIR){ | ||
if($item instanceof LeatherPants){ | ||
$armor = 2; | ||
}else if($item instanceof GoldLeggings){ | ||
|
@@ -529,7 +529,7 @@ private function getLeggingsArmorPoints() : int{ | |
* @return bool | ||
*/ | ||
private function isSwordWorn() : bool{ | ||
return $this->getMainHand() !== null and $this->getMainHand()->getId() !== ItemIds::AIR and | ||
return $this->getMainHand() !== null and $this->getMainHand()->getId() !== Item::AIR and | ||
($this->getMainHand() instanceof Sword); | ||
} | ||
|
||
|
@@ -539,22 +539,22 @@ private function storeToNBT(){ | |
$armor[0] = new CompoundTag("0", [ | ||
"Count" => new IntTag("Count", 1), | ||
"Damage" => new IntTag("Damage", 10), | ||
"id" => new IntTag("id", $this->boots !== null ? $this->boots->getId() : ItemIds::AIR), | ||
"id" => new IntTag("id", $this->boots !== null ? $this->boots->getId() : Item::AIR), | ||
]); | ||
$armor[1] = new CompoundTag("1", [ | ||
"Count" => new IntTag("Count", 1), | ||
"Damage" => new IntTag("Damage", 10), | ||
"id" => new IntTag("id", $this->leggings !== null ? $this->leggings->getId() : ItemIds::AIR), | ||
"id" => new IntTag("id", $this->leggings !== null ? $this->leggings->getId() : Item::AIR), | ||
]); | ||
$armor[2] = new CompoundTag("2", [ | ||
"Count" => new IntTag("Count", 1), | ||
"Damage" => new IntTag("Damage", 10), | ||
"id" => new IntTag("id", $this->chestplate !== null ? $this->chestplate->getId() : ItemIds::AIR), | ||
"id" => new IntTag("id", $this->chestplate !== null ? $this->chestplate->getId() : Item::AIR), | ||
]); | ||
$armor[3] = new CompoundTag("3", [ | ||
"Count" => new IntTag("Count", 1), | ||
"Damage" => new IntTag("Damage", 10), | ||
"id" => new IntTag("id", $this->helmet !== null ? $this->helmet->getId() : ItemIds::AIR), | ||
"id" => new IntTag("id", $this->helmet !== null ? $this->helmet->getId() : Item::AIR), | ||
]); | ||
$armorItems = new ListTag(NBTConst::NBT_KEY_ARMOR_ITEMS, $armor); | ||
|
||
|
@@ -565,7 +565,7 @@ private function storeToNBT(){ | |
$hands[0] = new CompoundTag("0", [ | ||
"Count" => new ByteTag("Count", 1), | ||
"Damage" => new IntTag("Damage", 10), | ||
"id" => new IntTag("id", $this->getMainHand() !== null ? $this->getMainHand()->getId() : ItemIds::AIR), | ||
"id" => new IntTag("id", $this->getMainHand() !== null ? $this->getMainHand()->getId() : Item::AIR), | ||
]); | ||
$this->entity->namedtag->setTag(new ListTag(NBTConst::NBT_KEY_HAND_ITEMS, $hands)); | ||
} | ||
|
@@ -623,11 +623,12 @@ public function sendHandItemsToAllClients(){ | |
|
||
private function createArmorEquipPacket() : MobArmorEquipmentPacket{ | ||
$pk = new MobArmorEquipmentPacket(); | ||
//ItemStackWrapper::legacy($this->helmet) ?? ItemStackWrapper::legacy(Item::get(Item::AIR)); | ||
$pk->entityRuntimeId = $this->entity->getId(); | ||
$pk->head = $this->helmet ?? Item::get(ItemIds::AIR); | ||
$pk->chest = $this->chestplate ?? Item::get(ItemIds::AIR); | ||
$pk->legs = $this->leggings ?? Item::get(ItemIds::AIR); | ||
$pk->feet = $this->boots ?? Item::get(ItemIds::AIR); | ||
$pk->head = $this->helmet ? ItemStackWrapper::legacy($this->helmet) : ItemStackWrapper::legacy(Item::get(Item::AIR)); | ||
$pk->chest = $this->helmet ? ItemStackWrapper::legacy($this->chestplate) : ItemStackWrapper::legacy(Item::get(Item::AIR)); | ||
$pk->legs = $this->helmet ? ItemStackWrapper::legacy($this->leggings) : ItemStackWrapper::legacy(Item::get(Item::AIR)); | ||
$pk->feet = $this->helmet ? ItemStackWrapper::legacy($this->boots) : ItemStackWrapper::legacy(Item::get(Item::AIR)); | ||
$pk->encode(); | ||
$pk->isEncoded = true; | ||
return $pk; | ||
|
@@ -636,7 +637,11 @@ private function createArmorEquipPacket() : MobArmorEquipmentPacket{ | |
private function createHandItemsEquipPacket() : MobEquipmentPacket{ | ||
$pk = new MobEquipmentPacket(); | ||
$pk->entityRuntimeId = $this->entity->getId(); | ||
$pk->item = $this->mainHand !== null ? $this->mainHand : Item::get(ItemIds::AIR); | ||
if ($this->mainHand instanceof Item) { | ||
$pk->item = ItemStackWrapper::legacy($this->mainHand); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The shorthand could be maintained here by using |
||
$pk->item = ItemStackWrapper::legacy(Item::get(Item::AIR)); | ||
} | ||
$pk->inventorySlot = 0; | ||
$pk->hotbarSlot = 0; | ||
return $pk; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ public function dataPacketReceiveEvent(DataPacketReceiveEvent $event){ | |
if($btnTxt === null){ | ||
return; | ||
} | ||
if($packet->transactionType !== InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY){ | ||
if($packet->trData !== InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you should use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wtf... no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please read the changes carefully. He is right. You should use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it works, that's the most important thing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The most important thing is that the code is written correctly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @supercrafter333 I made the requested changes for you, just review and merge my pull request into your branch supercrafter333#1 |
||
return; | ||
} | ||
$entity = $player->level->getEntity($packet->trData->entityRuntimeId); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove your username from the authors list. There are a large number of contributors to this project and it is preferred that people look at Github to get a full list of everyone's contributions. That is why the website is included in the plugin details.