block.setType() issues with spawning two Material.PORTAL

Discussion in 'Plugin Development' started by ferrago, Mar 4, 2014.

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

    ferrago

    I am basically trying to spawn a 1 wide x 2 tall nether portal, I know I need to disable the physics event for it which i believe i did. I am catching all BlockPhysicsEvent and canceling any that involve Material.PORTAL just to ensure the event for my portal is canceled. I can easily manually place a nether portal on top of a nether portal and it is fine, but doing this through code will only leave the last portal set left in place. I replaced all Material.PORTAL with Material.COBBLESTONE and it correctly places a 1 wide by 2 tall cobblestone. Anyone have any idea how to effectively do this. My block event and spawn codes are as follows.

    Code:java
    1. Location test = player.getLocation();
    2. test.setX(test.getX()+1);
    3. test.getBlock().setType(Material.PORTAL);
    4. test.getBlock().getState().update();
    5. test.setY(test.getY()+1);
    6. test.getBlock().setType(Material.PORTAL);


    Code:java
    1. @EventHandler
    2. public void onNetherPortalCreation(BlockPhysicsEvent event)
    3. {
    4. if (event.getChangedType() == Material.PORTAL)
    5. {
    6. event.setCancelled(true);
    7. }
    8. }
     
Thread Status:
Not open for further replies.

Share This Page