1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Making Villager Trade

Discussion in 'Plugin Help' started by Nemo404, May 4, 2020.

  1. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    Hi im trying to make a villager trade on pmmp. how can i achieve this?

    Previous Attempts
    Using https://github.com/many1337/VillagerTradeAPI
    The trade got closed after i clicked the Paper
    PHP:
    //VillagerTradeAPI
    $tags = new CompoundTag("Offers", [
             new 
    ListTag("Recipes", [
             new 
    CompoundTag("", [
             new 
    ByteTag("rewardExp"1),
             new 
    IntTag("maxUses"mt_rand(212)),
             new 
    IntTag("uses"0),
             
    Item::get(Item::PACKED_ICE02)->nbtSerialize(-1"buyA"),
             
    Item::get(Item::PAPER)->nbtSerialize(-1"sell")
    ])
    Using https://github.com/korado531m7/InventoryMenuAPI
    I got a bug whenever i make a trade i got more item than it should be. example
    I trade 2 Diamond for 1 Gold
    I got 2 Gold and the 2 Diamond back[/PHP]
     
  2. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    I already did a TradeAPI and realized that there is a bug in the transaction for the menu, you must cancel the Trade transaction via DataPacketReceiveEvent
     
  3. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
    TradeAPI is only for PM4 isnt it?
    Is PM4 the master branch of PMMP?
     
  4. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    I did not use TradeAPI pm4 I made a based on TradeUpdatePacket () with the code mirrored in one of the github, it is in the topics but I did not post the transaction part and my pc does not want to connect
     
  5. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    https://forums.pmmp.io/threads/villager-trade.9554/
     
  6. Nemo404

    Nemo404 Spider Jockey

    Messages:
    39
    GitHub:
    chaostixzix
  7. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    I didn't find these bugs when I tested the trade and my code was simple but as I said above, it canceled the DataPacket received from the transaction

    PHP:
    $t = new Trade("Teste");
    $t->addRecipe(Item::get(1), nullItem::get(2));
    $t->send($player);
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.