CustomiesDevs / Customies

A PocketMine-MP plugin that implements support for custom blocks, items and entities.
MIT License
112 stars 52 forks source link

ItemComponent MaxStackSize gets ignored on ItemPickup Event #107

Closed DemonicDev closed 1 year ago

DemonicDev commented 1 year ago

when taking an Item From Invetory, it is only 1 item in the stack, if i drop one of the two items, and pick it up, it will be added to the other stack, and it becomes to a 2Items stack while MaxStackSize was set to 1

use customiesdevs\customies\item\ItemComponents;
use customiesdevs\customies\item\ItemComponentsTrait;
use customiesdevs\customies\item\CreativeInventoryInfo;

use customiesdevs\customies\item\component\MaxStackSizeComponent;
use pocketmine\item\Item;
use pocketmine\item\ItemIdentifier;
class colt extends Item implements ItemComponents{
    use ItemComponentsTrait;

    public function __construct(ItemIdentifier $identifier, string $name = "Unknown")
    {
        parent::__construct($identifier, $name);
        $creativeInfo = new CreativeInventoryInfo(CreativeInventoryInfo::CATEGORY_EQUIPMENT, CreativeInventoryInfo::GROUP_SWORD);
        $this->initComponent("colt", $creativeInfo, 1);
        $this->addComponent(new MaxStackSizeComponent(1));
    }
DemonicDev commented 1 year ago

image i put an onInteract Event in, to get the MaxStackSize and current Stack Size of the Item. While Pocketmine thinks the Max Stack Size is 64, Customies thinks its 1. This Accurs to an Glitch, since the Item Pickup event is Triggered by Pocketmine

DemonicDev commented 1 year ago

Got Already A Fix:

in colt.php

class colt extends Item implements ItemComponents{
#to
class colt extends Gun implements ItemComponents{

and making Gun.php

use pocketmine\item\Item;
class Gun extends Item
{
    public function getMaxStackSize() : int{
        return 1;
    }
}
SwiftyMCPE commented 11 months ago

@DemonicDev bro what's your discord id