[?] Setting a block to a Nether Portal

Discussion in 'Plugin Development' started by caldabeast, Aug 29, 2012.

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

    caldabeast

    I have the following code, but when it runs, it ignores the part with the nether portal (id 90). Is there something i'm missing in terms of putting in Nether Portals?

    Code:java
    1.  
    2. @EventHandler
    3. public static void onPortalPlace(final BlockPlaceEvent e){
    4. final Player p = e.getPlayer();
    5. final Block b = e.getBlockPlaced();
    6. final Block up = b.getRelative(BlockFace.UP);
    7. final String name = olyWar.getName(p);
    8. if(olyWar.gameIsActive){
    9. if(b.getType() == Material.PORTAL && up.getType() == Material.AIR){
    10. if(olyWar.getTeam(p) == Team.RED) b.setType(Material.NETHERRACK);
    11. else if(olyWar.getTeam(p) == Team.BLUE) b.setType(Material.LAPIS_BLOCK);
    12. up.setTypeId(90,false); //the line of code in question
    13.  
     
  2. Offline

    chaseoes

    Does it work with a different block ID? Also test without any other plugins.
     
  3. Offline

    caldabeast

    I tried it with no other plugins, and it did the same.
    I replaced '90' with '1' and it did what it was supposed to do, its just not placing the Nether Portal.
    I know this is possible because it can be done with VoxelSniper, and as far as im aware, I did the same method it did..
     
  4. Offline

    chaseoes

    Can you place it by hand?
     
  5. Offline

    caldabeast

    The point is that the player places a portal in the location they want and it creates the wool for their team and puts a portal on top of it, so that wouldn't work. I tested it with End Portals and it works, but it would look and run a lot better and Nether Portals.
     
  6. Offline

    caldabeast

    bump. Any ideas?
     
  7. Offline

    QuantumDev

    Try cancelling the event after you place the block, I think the server will automatically remove any portals created by a person.
     
  8. Offline

    keensta

    Thing is with nether portals is they can not be placed alone. Due to the physics of minecraft.

    So what do you do you edit it using the physics events.
    Code:java
    1.  
    2. @EventHandler
    3. public void onBlockPhysics(BlockPhysicsEvent ev){
    4. if (ev.isCancelled()) {
    5. return;
    6. }
    7. if(ev.getChangedTypeId() == 90){
    8. ev.setCancelled(true);
    9. return;
    10. }
    11. }
    12.  
     
  9. Offline

    caldabeast

    Ah! A BlockPhysicsEvent! Why didn't I think of that?
    Thanks! I'll try that tomorrow!
     
  10. Offline

    caldabeast

    Thanks! That did the trick!
     
  11. Offline

    chaseoes

    Exactly why I asked if you could place them by hand.

    But, whatever.
     
Thread Status:
Not open for further replies.

Share This Page