Skip to content

Commit

Permalink
Merge pull request #10 from FoxWorn3365/pmmp5-dev
Browse files Browse the repository at this point in the history
Fixed a small problem with PMMP4
  • Loading branch information
FoxWorn3365 authored Jun 26, 2023
2 parents 9749565 + 8e0f3db commit 64c4789
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/FoxWorn3365/Shopkeepers/Menu/ShopInfoMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public function create() : InvMenu {
$inventory->setItem(20, Factory::item(388, 0, "§o§lSales\n\n§r§oThis function will be implemented with the §bSales & Shops §r§oupdate AKA §lv1.0"));

// Summon option
$inventory->setItem(22, Factory::nbt("0a0000010005436f756e74010800044e616d65000f6d696e6563726166743a736b756c6c02000644616d616765000304000f504d4d504461746156657273696f6e000000000000000100", "§lSummon"));
$head = Utils::getItem("minecraft:skull");
$head->setCustomName("§r§lSummon");
$inventory->setItem(22, $head);

// Misteryous option
$inventory->setItem(24, Factory::barrier("§oUnknown\n\nThis function will be implemented with the §bSales & Shops §r§oupdate AKA §lv1.0"));
Expand Down
7 changes: 7 additions & 0 deletions src/FoxWorn3365/Shopkeepers/utils/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\ListTag;

// Network
use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;

final class Factory {
public static function sign(int $meta, string $text) : ?Item {
$item = Utils::getIntItem(160, $meta);
Expand Down Expand Up @@ -70,4 +73,8 @@ public static function nbt(string $nbt, string $name, int $count = 1) {
$item->setCount($count);
return $item;
}

public static function itemStack(int $id, int $meta, int $netId, int $count = 1) : ItemStack {
return new ItemStack($id, $meta, $count, $netId, new CompoundTag(), [], []);
}
}
4 changes: 2 additions & 2 deletions src/FoxWorn3365/Shopkeepers/utils/ItemUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ public static final function encode(Item $item, bool $toObject = true) : array|o
}

public static final function decode(int $id, int $meta, int $network) : ?Item {
return (new TypeConverter())->getItemTranslator()->fromNetworkId($id, $meta, $network);
return (new TypeConverter())->netItemStackToCore(Factory::itemStack($id, $meta, $network));
}

public static final function objectDecode(object $object) : ?Item {
return (new TypeConverter())->getItemTranslator()->fromNetworkId($object->id, $object->meta, $object->network);
return self::decode($object->id, $object->meta, $object->network);
}

public static final function typeDecode(object $object) : ?Item {
Expand Down

0 comments on commit 64c4789

Please sign in to comment.