int yp = y + j;
int zp = z + l;
Block blockAbove = supertile.getWorldObj().getBlock(xp, yp + 1, zp);
if(filter.equals(supertile.getWorldObj(), xp, yp, zp) && (blockAbove.isAir(supertile.getWorldObj(), xp, yp + 1, zp) || blockAbove.isReplaceable(supertile.getWorldObj(), xp, yp + 1, zp)))
validPositions.add(new ChunkCoordinates(xp, yp + 1, zp));
}
scanned = true;
}
if(!validPositions.isEmpty() && !supertile.getWorldObj().isRemote) {
Block blockToPlace = null;
if(stackItem instanceof ItemBlock)
blockToPlace = ((ItemBlock) stackItem).field_150939_a;
else if(stackItem instanceof ItemReed)
blockToPlace = ReflectionHelper.getPrivateValue(ItemReed.class, (ItemReed) stackItem, LibObfuscation.REED_ITEM);
if(blockToPlace != null) {
if(blockToPlace instanceof ISpecialFlower)
return;
ChunkCoordinates coords = validPositions.get(supertile.getWorldObj().rand.nextInt(validPositions.size()));
if(blockToPlace.canPlaceBlockAt(supertile.getWorldObj(), coords.posX, coords.posY, coords.posZ)) {
supertile.getWorldObj().setBlock(coords.posX, coords.posY, coords.posZ, blockToPlace, stack.getItemDamage(), 1 | 2);
if(ConfigHandler.blockBreakParticles)
supertile.getWorldObj().playAuxSFX(2001, coords.posX, coords.posY, coords.posZ, Block.getIdFromBlock(blockToPlace) + (stack.getItemDamage() << 12));
validPositions.remove(coords);