Block Inventory

Discussion in 'Plugin Development' started by awesomer3, Jun 30, 2014.

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

    awesomer3

    Hello
    I am stuck on how to make an inventory like a chest for piston extensions.
    When a player click a piston head it will be like a chest and an inventory will open witch you can put items in and then retrieve them. But i dont know how to make a inventory for each block
    Please help
    -awesomer3
     
  2. Offline

    Garris0n

    Save the inventory in a map with some sort of index, such as the location of the block.
     
  3. Offline

    awesomer3

    Garris0n can i have some sample code or can you explain it
     
  4. Offline

    ulsa

    well for the head you need to do 2 ways of checking .. you can check if its piston head blocks when piston is extended
    and for retracted pistons
    you can check which way piston is facing "find the head side"
    get the block that player is facing when right clicking "has to be piston"
    get which side player is looking "has to be the side with head"
    and if they equal open the menu
     
  5. Offline

    Garris0n

    This is a section for helping you with your code, not writing code for you.
     
  6. Offline

    awesomer3

    Garris0n ik i just need help i dont want you to do it for me just give me an example code for me to build on
     
  7. Offline

    ulsa

    also here is what i use for checking the face of a block
    Code:java
    1. if (is.getType() == Material.GLASS_BOTTLE)
    2. {
    3. List<Block> blocks = event.getPlayer().getLastTwoTargetBlocks(null, 5); //5 is the range
    4. if (blocks.size() > 1)
    5. {
    6. BlockFace face = ((Block)blocks.get(1)).getFace((Block)blocks.get(0));
    7. event.getPlayer().sendMessage(face + " test");
    8. }


    for range if you set it 5 and try clicking away "more than 5 blocks" it will not give correct result . so make range bigger if you want to get a correct result on far range
    "this code is on @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event)" so on rightclicking it gives you the face of block you are looking at
     
Thread Status:
Not open for further replies.

Share This Page