[solved] Why does this portal not form?

Discussion in 'Plugin Development' started by phondeux, Mar 3, 2012.

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

    phondeux

    I've written a stupid little plugin that creates stupid little portals one block wide instead of two, as a proof of concept. When it creates the portal in the latest dev builds I only get the block at the top. Why?
    Code:
      @EventHandler
      public void onPlayerInteract(PlayerInteractEvent event) {
          if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
              if (event.getPlayer().getItemInHand().getType() == Material.BLAZE_ROD) {
                  // Make Stupid Obsidian Gate
                  Block block = event.getClickedBlock();
                  Block a1 = block.getRelative(0, 0, 1);
                  Block a2 = block.getRelative(0, 1, 1);
                  Block a3 = block.getRelative(0, 2, 1);
                  Block a4 = block.getRelative(0, 3, 1);
                  Block a5 = block.getRelative(0, 4, 1);
                  Block a6 = block.getRelative(0, 4, 0);
                  Block a7 = block.getRelative(0, 4,-1);
                  Block a8 = block.getRelative(0, 3,-1);
                  Block a9 = block.getRelative(0, 2,-1);
                  Block a10 = block.getRelative(0,1,-1);
                  Block a11 = block.getRelative(0,0,-1);
                  block.setType(Material.OBSIDIAN);
                  a1.setType(Material.OBSIDIAN);
                  a2.setType(Material.OBSIDIAN);
                  a3.setType(Material.OBSIDIAN);
                  a4.setType(Material.OBSIDIAN);
                  a5.setType(Material.OBSIDIAN);
                  a6.setType(Material.OBSIDIAN);
                  a7.setType(Material.OBSIDIAN);
                  a8.setType(Material.OBSIDIAN);
                  a9.setType(Material.OBSIDIAN);
                  a10.setType(Material.OBSIDIAN);
                  a11.setType(Material.OBSIDIAN);
                  // Fill Stupid Obsidian Gate with Portal Blocks
                  Block p1 = block.getRelative(0,1,0);
                  Block p2 = block.getRelative(0,2,0);
                  Block p3 = block.getRelative(0,3,0);
                  p1.setType(Material.PORTAL);
                  p2.setType(Material.PORTAL);
                  p3.setType(Material.PORTAL);
              }
          }
      }
    Nobody has any idea? :)

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

    phondeux

    Bump Again

    Sort of solved ...

    For the portal blocks I should use the following;
    Code:
    p1.setTypeId(Material.PORTAL.getId(), false);
                  p2.setTypeId(Material.PORTAL.getId(), false);
                  p3.setTypeId (Material.PORTAL.getId(), false); 
    This works well enough. One caveat; the gate initially looks broken, still, but if you relog you see all of the proper portal blocks.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
Thread Status:
Not open for further replies.

Share This Page