Solved Giving a Villager a Viewable Inventory

Discussion in 'Plugin Development' started by bballheat, Jul 3, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    bballheat

    I'm working on my new plugin and was gonna make a shopkeeper, so I decided I would use a villager. The only problem is that I want the villager to have an inventory and whenever you take something from it's inventory you pay the villager if you have enough money. I think I can do the paying part, but how do I give it the inventory? Thanks if you ca help!

    Cause I'm using my own economy.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  2. Offline

    xXSilentYoshiXx

    Interact Listener class:
    Code:
        @EventHandler
        public void onVillagerInteract(PlayerInteractEntityEvent e) {
            Player player = e.getPlayer();
            Entity entity = e.getRightClicked();
           
            if (entity.getType() == EntityType.VILLAGER) {
                e.setCancelled(true);
               
                //Add a new inventory here
            }
        }
    There's a "Open New Inventory" forum thread somewhere deep in Bukkit. If I can find it, I'll get back here and give it to you. :)

    @reference T3h Cr33p3r (<--- I don't know how to use this)

    lol, sorry XD

    T3h Cr33p3r
    Oh, OK. XD I forgot about that. :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  3. Offline

    bballheat

    I was just gonna do this but with PlayerInteractEvent.. which is impossible lol. Thanks! This will help, and I found another thread that shows how to create inventorys.
     
  4. Offline

    xXSilentYoshiXx

    bballheat
    No problem! I love to help other people out with problems :)

    And is it from a guy's profile picture with a crown? If so, that's what I was looking for. :)

    T3h Cr33p3r

    It's a lot easier to use
    Code:
    This
    instead of
    Code:java
    1. This

    .

    T3h Cr33p3r
    Using syntax=java makes it so that you have to re-format it every time you edit what you type. :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  5. Offline

    bballheat

    No it wasn't :( but the link is: https://forums.bukkit.org/threads/tutorial-creating-a-inventory.146547/ if you still need it. Also thanks for adding that e.setCancelled() to close the inventory because that's exactly what I needed too, just never though of that.



    Ok. EDIT: Oh and I am a BEAST and handling indents!!! :p
     
  6. Offline

    xXSilentYoshiXx

  7. Offline

    bballheat

    Ok lol I got all the info I needed. Thank you for your help... and tips.
     
  8. Offline

    xXSilentYoshiXx

    bballheat
    Edit Thread > Title [Or whatever] > Prefix > SOLVED
     
Thread Status:
Not open for further replies.

Share This Page