Correctly grabbing blocks with onBlockPlace on a snow tile

Discussion in 'Plugin Development' started by nossr50, Feb 14, 2011.

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

    nossr50

    It seems that when players place a block on snow it does not return the correct block they have placed for the event. It might be because of how snow is a block and gets replaced when you are placing a block. Does anyone know a good work around to grab the block you are placing in this event?
     
  2. Offline

    Zeroth

    Did you ever figure this out? i just ran into this problem and am about try some tests.
     
  3. Offline

    magicksid

    Code:
    
    public void onBlockPlace(BlockPlaceEvent event) {
    
    	Block placedBlock = event.getBlock();
    	Location blockLocation = placedBlock.getLocation();
    	if (event.getBlockReplacedState().getTypeId() == 78)) {
    		//block was placed on snow, subtracy one from Y to compensate
    		double Ypos = placedBlock.getLocation().getY();
    		blockLocation.setY(Ypos - 1);
    //load the block at blockLocation, and do whatever you want
    	}else{
    //normal block placement
    	}
    }
    
    try that
     
Thread Status:
Not open for further replies.

Share This Page