Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inv Bug #236

Open
Driwen4356 opened this issue Sep 23, 2023 · 2 comments
Open

Inv Bug #236

Driwen4356 opened this issue Sep 23, 2023 · 2 comments

Comments

@Driwen4356
Copy link

I have a problem with the discard on my server, it's bug my inventory

Minecraft.2023-09-24.00-38-54_Trim_Trim.3.mp4
@Muqsit
Copy link
Owner

Muqsit commented Sep 23, 2023

Can you share the relevant code and describe the intended outcome of it?

@Driwen4356
Copy link
Author

Driwen4356 commented Sep 24, 2023

``
$menu->setListener(function (InvMenuTransaction $transaction) use ($player,$menu): InvMenuTransactionResult {

        $blockclick = $transaction->getItemClicked()->getBlock();
        $itemin = $transaction->getIn();


        if ($transaction->getItemClicked()->getVanillaName() === "Stained Glass Pane") {
            $player->sendMessage("You cannot take apples out of that inventory.");
            return $transaction->discard();
        }

        if ( $itemin->getVanillaName() === "Nether Wart" and $itemin->getCount() == 64){
            $menu->getInventory()->setItem(15, VanillaBlocks::WOOL()->setColor(DyeColor::LIME())->asItem()->setCustomName("§aTransformer"));
        } else $menu->getInventory()->setItem(15, VanillaBlocks::WOOL()->setColor(DyeColor::RED())->asItem()->setCustomName("§c64x cannabis requis"));

        if ($blockclick instanceof Wool) {
            if ($blockclick->getColor() === DyeColor::LIME()) {
                $menu->getInventory()->setItem(11, VanillaItems::AIR());
                $rdm = random_int(1, 50);

                if ($rdm == 35) {
                    $player->getInventory()->addItem(VanillaItems::DYE()->setColor(DyeColor::GREEN()));
                    $player->sendMessage("§pVous avez reçu un bedo !");
                } else {
                    $player->sendMessage("§cVous n'avez pas eu de chance pour transformer votre cannabis !");

                }
            }
            return $transaction->discard();
        }
        return $transaction->continue();
    });

``
if I put nether wart in slot 11, the green wool appears in slot 15 then if I click on it it launches a random event to give me a reward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants